I’ve been using Codeigniter for the past two years and really have become a big fan, but over the past year I’ve found myself writing more and more javascript than PHP.
In the begining, I would write everything with PHP, but now I find myself using $.ajax all the time. And I sort of feel like Im repeating myself between javascript and php.
I know that CI does give you some good control over ajax, but Im still having two write a ton of javascript and I’d like to consolidate if at all possible.
I guess what I am looking for is a php framework that integrates tightly with jQuery’s $.ajax.
I use this piece of code in Javascript. Backend wise things are organized in a MVC type of organisation, so things affecting one module are usually grouped together. In general I also create a sperate module for a seperate model, but in some cases you may deviate from this principle.
My setup is with symfony at the back and plain jquery at the front. There are some approaches that automatize this part, like http://javascriptmvc.com/, I find it too restricting in many parts. Here is my workflow for integrating php and jquery.
PHP
Execute a piece of code and wrap it inside a try/catch block. This way error messages may be propagated to the frontend. This method helps in that regard to convert exceptions to a readable error. (to debug from json).
For error handling I often use this to parse errors.
Javascript side
Note: the error callbacks are very nice if you combine them with something like pNotify