Reputation: 7055
I'm developing android app. It's some sort of social network. Where user can add friend and some few stuff. I've been working on php for quite a time now. But android is totally new for me. The app will be served by a web service. My android skill are not good. So total time I spend on working on android part is more. So I'm thinking is there any framework that can be used to serve my application. With this I can reduce time to implement web service. I know some of framework but as I have not worked with them, I don't know how much they can be extended to fit in my need. OR should I implement it by my own without any framework ?
All the suggestions, advises will be extremely helpful.
Upvotes: 1
Views: 3747
Reputation: 828
In my opinion you should definitely go with a framework, so you can concentrate more on developing the Android app.
Important is, that you choose your backend framework wisley. So it should be a lightweight and/or RAD (Rapid Application Development) framework, which enables you to use code generation for common patterns to get startet very fast.
I can recommend Ruby on Rails. If you want to stick with PHP, then my recommandation would be Symfony 2 or Kohana. Using those frameworks, you should concept and implement an API, preferably RESTful, which provides your Android application with data and can be used later on for all other kind of mobile apps or third party applications.
If you go with Symfony 2 you can have a look for the FOSRestBundle - a bundle which provides tools to create a RESTful API.
Further on, Symfony 2 comes with a very good documentation - including a getting started section, as well as a cookbook.
So,... happy coding. :)
Upvotes: 4
Reputation: 8519
I don't think a framework is really needed here. An efficient way to communicate between your server and Android is through the JSON data format. It's smaller than XML, but it's just as easy to use.
For example, to request the list of friends, you could send a request like this:
http://www.example.com/android.php?do=friends
And send your authentication cookies just like with the desktop site. A response would look like this:
{
"friends": [
{
"name": "John Lua",
"age": 19,
"friends_since": 32423434
},
...
]
}
In the production version, you can of course leave out the indentation and other spacing.
It is trivial to generate this output in PHP, but if you want, you can use a function like this: http://www.php.net/manual/en/function.json-encode.php
Parsing it again in Java (on Android) can be done with a library: http://json.org/java/
You would request this response with a normal web request in Java. You can find information on web requests with cookies here: http://www.hccp.org/java-net-cookie-how-to.html
Serverside, you would handle Android clients just like desktop clients, only with a different output format.
Upvotes: 2