Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Migrating a PHP-MySQL App to Titanium - What is possible?

Hi,
i am new to titanium. looks like a very nice development tool.

i have developed a PHP-MySQL App based on jQuery and the CakePHP Framework. Now i want to port this app to titanium. To turn it to an application which don't need internet access.
I have two ideas to port the app to titanium. But i am not sure if one of them might work.

But first here are some closer information about my PHP MySQL app.
As i said before the app is based on the CakePHP Framework. The CakePHP Framework is using Routes inside a .htaccess-file to mange different urls. For example, if i want to add maybe the a project to the database i post the form data to an url like the followig : http://MyApp/projects/add/
The next important fact is that i use database relations. For example user hasMany Projects. In CakePHP it is very simple to use database relations.
An the last fact: the complete server/client communication is ajax and json based.

OK, here is the fist one:
Titanium is able to run PHP. I want to include my CakePHP Project into the titanium app and just rebuild the UI and migrate my CakePHP project to SQLite.
But there is one problem. How do i send the data to the CakePHP project? I think i can not post the data via ajax to http://MyApp/project/add? But is this working: app://MyApp/project/add/, if i place my CakePHP Files to resources folder? CakePHP is using the mod_rewrite apache module to manage short url's.

The second one:
Rewriting the complete app in JS in Titanium. But is there any thing to realize database relations easily?

OK. That's all. Or does someone has an other idea?

And please excuse my english ;-)

Thanks a lot,
Nic

— asked July 13th 2010 by Nico Marks
  • cakephp
  • mysql
  • php
0 Comments

2 Answers

  • I've only been evaluating appcelerator for less than a day now, but perhaps I can share some of my first impressions.

    One of the reasons I've been looking into appcelerator is to also see how parts of my company's HTML/PHP/MySQL sitebuilder application could be moved 'offline' to the desktop.

    In all honesty, we certainly wouldn't undertake a full port of our website builder system as it stands. We are currently looking at how we can remove MySQL from the equation first, make it file based. Our thinking is that the more simple and more smaller an application, with the less dependencies, the easier it should be to port. Simplify first, port second.

    But even with MySQL out of the picture, I think the main issue might then be the Titanium desktop architecture. With a web-based application the architecture of is:

    browser > web server > php

    whereas it seems that with Titanium it is more:

    browser > php

    (perhaps with Titanium in the middle but not with what you'd expect from a web server in the middle)

    What seems to be missing is the web server part. I was expecting Titanium to package up a mini apache web server as well as packaging up a webkit browser and php, but this doesn't seem to be the case. It looks like php files are called using CLI (command line interface). My testing so far shows that if you have a HTML file in the Resources folder with a HTML form handled (HTML form action) by a PHP file in the Resources folder, it will work if you use HTML form method get (adding the parameters to the URL), but not a HTML form method post (http posted). This is possibly indicating that the PHP file is not running as a HTTP server program. So if form post isn't available that could be mean a lot of workarounds involved for a lot of PHP applications, not simple ports, since get alone isn't that useful and is quite limited (field sizes etc).

    As I said, I've only been looking at this for a day, and I could very well be wrong. I hope that I am wrong. But I thought I'd share my initial concerns anyway.

    — answered July 14th 2010 by Paul Ireland
    permalink
    1 Comment
    • I've posted some example PHP form code in another discussion.

      — commented July 14th 2010 by Paul Ireland
  • Titanium includes a recent iteration of WebKit that employs SQLite in the browser. It can be accessed by JavaScript in the browser itself, but I do not believe there's a method for PHP to access the SQLite server in the browser itself.

    I read something about using the SQLite3 extension in PHP, but I do not believe it comes installed with that. Perhaps that's one of the things they'll update in Titanium Desktop 1.1 when it comes out sometime in the Fall.

    — answered September 13th 2010 by Greg Bulmash
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.