10

I'm evaluating PHP frameworks for several upcoming projects, with the goal of using the same framework for all of them. An unusual aspect is that they are NOT standard browser-based applications, they will all be accessed by custom apps that expect XML or JSON (currently undecided).

Most PHP frameworks such as Yii, CodeIgniter, CakePHP seem designed around the reasonable assumption that the client app will be a browser-- e.g., using cookies to manage persistence, redirects after POSTs, etc.

While I'm sure I can get any of the above frameworks to do the job, are any of the major frameworks "better" suited to client-app agnostic application development?

justkevin
  • 3,089
  • 3
  • 28
  • 33

6 Answers6

6

Actually Recess PHP sounds perfect for that... its inherently restful before anything else.

Updated: I've also been playing with Slim Framework lately. That is a pretty cool little tool that basically is the PHP equivalent of Express.js for node. It is extremely efficient, lightweight, and test-driven.

Kristian
  • 21,204
  • 19
  • 101
  • 176
6

Of the 'big' ones (CI, Kohana, Zend, Cake, Symfony) I think the newer Zend has the best support for RESTful webservices, but earlier versions of Zend framework had woefully lacking rest controllers. I've created my own for Zend and just use them.

If you really want a webservice tailored framework there are a bunch of smaller projects, none which I think have traction anywhere close to the tipping point to where I'd bet the farm on them (or use for more than a demo project).

My advice is stick to a framework you already know, build out your own rest controllers (if currently lacking). Some basic functions to take the output and convert it to XML, json, etc... may need to be created, but you'll spend less time than trying to learn a new framework. Plus, with a biggie, you won't be stuck with having to maintain an abandon-ware code base someone got tired of keeping up with.

Ray
  • 40,256
  • 21
  • 101
  • 138
1

Symfony2 has an interesting concept as long as you are HTTP focussed (and additionally, it has some CLI (command line interface), too).

It's less a framework but more a framework library in which you can pick the parts you need with a small kernel that provides basic HTTP abstraction. This lightweight concept helds enough room to cover a lot for your application logic while not being too inversive.

Additionally it's well tested, has a defined API and allows easy extension with dependency injection and so called bundles.

If you start new and you use PHP, start with symfony2.

hakre
  • 193,403
  • 52
  • 435
  • 836
0

Simple web services can be created very easily. You are not going to use any framework but as you will go for production...you need to worry about security and flexibility.

Actually it will be really easier if you use a framework to manage your API. I suggest you to go for a lightweight framework.

The whole point of frameworks is to handle common tasks and things that are otherwise tedious. REST API's are commonly built with PHP, so a plethora of frameworks exist. Personally, I would use a lightweight framework like slim simply to handle things like URI routing, parsing/cleaning request data, and generating responses.

You have a lot of such options: http://davss.com/tech/php-rest-api-frameworks/

Vishal Kumar
  • 4,419
  • 1
  • 25
  • 31
0

I recommend Zend Framework for odd jobs like this, specifically because it was written in such a way that you can use bits and pieces of it without needing to adopt the behavior of the framework as a whole. For example, in my application, I use the Zend_Db portion of the framework for ORM- and database-related functions, but I use other objects and frameworks for other parts of the application.

As you point out, most other frameworks are written with many assumptions about the type of application you are hoping to build (one of the disadvantages of the convention-over-configuration paradigm).

Jazz
  • 1,435
  • 1
  • 15
  • 23
0

Surely people have stopped using restful services by 2012?

If your familiar with Ruby on Rails Yii PHP framework is worth looking into.

Perhaps worth spending an hour with each framework and seeing which one you find the easiest to use.

Chris Herring
  • 1,412
  • 9
  • 10