I have just “finished” coding up a relatively involved web service in PHP. The code base is now a bit of a mess due to last minute requests, changes, add-ons, the usual.
I tried to code it as lightly as possible and in a manner that would maximise performance.
Therefore, I didn’t use any frameworks like Zend or any ORMs like Doctrine.
I was wondering if there are any frameworks or design patterns that exist for the sole purpose of building APIs/web services in PHP?
I’m thinking of a refactor and I want to make sure now I know exactly what’s involved I can build this thing properly.
I apologize in advance for the self-reference here to my own framework – there’s no way for me to help you otherwise since I don’t use anything else. I’m not advertising, since it’s not public.
As I said in my comment, I think a good web front-end framework shouldn’t mean it is a poor web service framework.
Because I was unsatisfied with the restrictive way any of the popular PHP frameworks (CodeIgniter, CakePHP, Kohana) processed requests, as well as their size, I wrote a framework that is designed for really only two purposes, process a request and determine an action to take, and then separate the code for that action from the view (response).
The design pattern I use is this:
/users– User list/user/*– User identified by the value where*is./user/*/delete– Delete the user/posts– List posts/post/*– View post*UserActions::saveUserto be executed if the HTTP method isPOST. The reason it’s only executed on POST is to enable output and input to have the same URL.SecurityManager::authorize) to check for authorization and iffalseis returned, it redirects to a path of your choosing.The reasons I believe this design pattern works well for Web Services:
POST, check for other methods too).