I'm creating a small web application. There is not any advanced functionality, just fundamental queries from the database.

The web site itself enables log inches via usual means and Facebook Connect, after that it has some CRUD functionality.

I'll be developing a 'native' Facebook application for this, aswell being an apple iphone application as well as an Android application.

My real question is, what's the easiest method to keep up with the codebase?

I've carried this out before where I produced a fundamental API that permitted me to include, edit and remove database records, and that i then used HTTP Posts the API across all platforms. This managed to get very simple to keep up with the codebase, fix bugs, make updates, etc, when i only needed to update one place. The person applications themselves only really had some skinning and more cURL demands. Even though this labored ideal for the mobile applications (apple iphone and Android), it made unnecessary http demands online and Facebook application.

What's the easiest method to approach this case? Must I create 2 websites (Facebook and normal website) as well as an API? This could allow it to be harder to keep, but a lot more stable and faster. Just an API, which may allow it to be simple to maintain?

The codebase is PHP in CodeIgniter with MySQL because the database.

I believe you need to create an API with php classes, after which possess a HTTP API wrapped around it.

PHP class API:

<?php // myproducts.class.php

class MyProducts

title, $cost)

  



And your HTTP API:

<?php // api/items.php

// read HTTP Publish and decode it as being json

$postParams = json_decode(file_get_contents('php://input'))

if (!$postParams)

  throw new exception("Couldn't decode Publish data, invalid JSON.")

// run the preferred action

$classMethod = $postParams['action']

$arguments = $postParams['arguments']

$result = call_user_func_array(array('MyProducts', $classMethod), $arguments)

// print result as JSON

print json_scribe($result)

With this particular, it is simple to write an obj-c class to speak to the HTTP API. It could look something similar to:

NSData *postData = [@"" dataUsingEncoding:NSUTF8StringEncoding]

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:API_URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]

[request setHTTPMethod:@"Publish"]

[request setHTTPBody:postData]

NSHTTPURLResponse *urlResponse = nil

NSError *error = nil

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error]

NSLog(@"response: %@", [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease])

Clearly you will want to find an Obj-C API for encoding/decoding JSON. I'm using TouchJSON

We've been using Kohana since The month of january. We moved from Codeigniter, which is quite lovely. The cascading down file system causes it to be simple to organize your code.

A good example of multi-platform me is Android. We have pressed most the logic into php, only then do we pull that into an Android WebView, with a few assistants for connectivity and speed, also it shows just like a native application.

With Kohana, just produce a JSON view for API calls. You should check the request to ascertain if it's AJAX to determine whether to utilize a JSON or any other view.

To determine between browser or mobile application, we set a person agent string unique to the mobile application, then test for this php-side. Also, you will find there's view hierarchy that allows us possess a couple of different layout files. There's one for mobile demands, one for that web application, one for any certain kind of user, etc.

Overall, Kohana is much more flexible than Codeigniter, along with a great base to construct an internet application and API on.

The down-side to Kohana would be that the documentation is quite poor. However, when you begin using it, you'll learn it rapidly. The codebase is neat and readable through.

Sorry basically continued about Kohana to much, but, if you wish to use php and also have the versatility you appear to crave, this is actually the starting point, IMHO.