How to Use PHP in IPhone Applications - iphone

I need to create an iPhone application using Facebook.
The facebook FBConnect API supports FQL which is similar to SQL Queries.
I would be able to create the application easily using PHP as compared to Objective-C.
So if there is any way to create an iPhone application using PHP please reply to me.
Thanks.

Well, if you are developing something for jailbroken devices , yes it is possible to use PHP (you have to install it first from Cydia).Also note that you should implement a SQLite database if your app/script needs database functionality (you can't run a MySQL server natively on iPhone ATM).
But, as pekka mentioned, this is a really bad idea, because you must set up first a lighttpd web server on iPhone (not really comfortable), or if you're planing to implement a CLI PHP script, you should first launch it (using some C functions like pipe(), dup2(), fork(), execl()) and then parse its output inside your -not-so-Objective-C- iPhone app.
So think it again...

Related

Where can I find out about coding a website to my app?

I just found out that an iPhone can act as a web server to access the app's data. I'm using Xcode. How do I extend my app's capabilities so that users can edit app data using a Mac. Where can I learn about this? Can you give me summary and a website please?
I hope it's using Apache Tomcat. I suppose I have to build a website to process and display the app's data. I wonder if iPhone supports jsp since it's using UNIX. I really don't want to use PHP.
Currently Money Manager has that feature.
Searching for embedded iOS web server returns a few solutions:
Run a webserver on an iOS device
A small, lightweight, embeddable HTTP server for Mac OS X or iOS applications
Lightweight GCD based HTTP server for OS X & iOS
You will be unlikely to fit php or tomcat onto an iOS device; the lack of memory and processing power will be technically challenging.
Apple will also likely take a negative view of the inclusion of a general purpose scripting language in any app your submit to the App Store.

How to access native SQLite database with an application

I want to make an application for iphone, ipad, and android using HTML 5.
This application will create a SQLite database or place a prefilled SQLite database file when it is installed on ipad/iphone/android.
I want to keep it in a folder where my application is installed.
eg
ApplicationName- Files (where I have all the files for the application)
ApplicationName- DB (where I will have my sqllite database)
I want to connect to SQLiteDB using javascript.
Can I access the db at a particular location from my application using Javascript or jquery.
Can you suggest me some way I can get into this.
I would advise you to look at Apache Cordova (old Phonegap) to see how they handle things or use they own solution for this kind of thing.
But if you really want to walk alone, you need to build 2 sets of frameworks to call native code, or use web sql database(inactive) or something similar.
iOS
http://blog.techno-barje.fr/post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript/
Android
http://labs.mwrinfosecurity.com/blog/2012/04/30/building-android-javajavascript-bridges/

Can PhoneGap apps use server pages to load on it?

I am trying to do web apps using PhoneGap framework for iOS. I need to know whether PhoneGap loads page from server or not, I mean , can I use server side scripting language like php, pyhon, etc?
And if I used those scripting language, can I use phone native feature like camera?
Also for data storage there may be feature, I heard opendatabase can be used for online / offline database. Please anyone help me to figure out these things.
Waiting for good answer.
Thanks
Server side scripts cannot be loaded from within the app, however you can certainly call out to PHP, Python, etc running on a server from the app using AJAX, XHR, etc.
I gave an example in the question below:
How can get value in phonegap which is returned by php class?

Possible to share SQLite DB between PhoneGap and Native code?

I am writing a native iPhone and Android app using Sencha Touch inside Phonegap and my client is very keen for me to include Analytics.
The application needs to function happily offline so I need an analytics solution that can remember activity occurring while offline and updating the server once online again.
My thoughts are to store events from within the JS to a store that can be checked at a regular interval on the device and posted to the server.
My question is whether a SQLite DB could be used for this using the Phonegap API and whether this DB could then be accessed from the native code?
I suspect not and that the best option would be to write to a text file.
Any thoughts or suggestions gratefully received.
The solution to this seems to be to write a Phonegap Plugin that lets you call a method from inside Phonegap to a method in your native application.

Client-server web app with both client AND server running on iPhone - is this possible?

I'd like to build a simple native iPhone app with tools traditionally used for web apps.
I would prefer to use something like jQTouch and Rails, but I want it to work offline (not require an internet connection or a server).
Is there a framework that enables simple creation of native iOS aps by encapsulating a lightweight web server and a server-side app framework (Rails or something simpler and more lightweight that can run on a phone), thus allowing you to write the client side code in HTML+JavaScript ?
If there is not such a thing, is there a way to create an app (with HTML+JS) that basically only has a client-side component with persistent data storage?
Thanks.
Have you tried Phonegap?
www.phonegap.com
You write your app in HTML/CSS/JavaScript.
You access the phones APIs through JavaScript - boom!
Also; Appcelerator Titanium would be an option: http://www.appcelerator.com/
-IMO Titanium is more powerful, and offers a more native look.
Why would you want to run a webserver off of the iPhone?
Is it so that you could send back data to the mothership?
Yes, you can included a lightweight http server running in another thread inside your iPhone app, and have your UIWebView connect to it. But unless you are going to do a fancier web server that generates dynamic content, it might be easy to just download your HTML/CSS/Javascript content to a local directory, and then point any URLs to those local files when offline.