Question

I've been writing PHP web applications for some time, and have come across very nice Javascript frameworks, such as JQuery, ExtJS, Scriptaculous, etc. I can't say the same about the PHP side - I always coded that part of the client-server dialog from scratch.

I've used CodeIgniter (http://codeigniter.com/) and it is nice, but doesn't deal with AJAX as a whole - rather providing input checking, image manipulation, and some output helpers.

Is there a standard PHP library/class/framework out there that deals/integrates with Javascript frameworks? Something that can catch users' responses/requests, validate identity and input, provide progress status, keep track of sessions, be aware of asynchronous events, etc.

Was it helpful?

Solution

The Zend Framework is integrated with Dojo Toolkit. I haven't used the latest Zend Framework yet, but I do know that in the past, it has proven to be reliable.

OTHER TIPS

There might be one but I can't imagine why. An AJAX request looks and acts just like an HTTP request from the perspective of the server. You can get and set cookies. All the environment variables that you would expect from an HTTP request are there. All of the HTTP verbs work as do any of the header fields.

In the next major release 1.5 CakePHP will come with jQuery.

Sajax is one of a number of libraries that provide an easy way to link callbacks from client-side (JS) to server-side (PHP). Another library which does something similar is JPSpan however I am not sure if it is still actively supported. I have only done minor experiments with these two libraries so your mileage may vary.

Using a library is fine as a convenience once you understand the concept, and you probably do, but for others reading this I suggest doing it by hand a few time first and really understanding it. I also recommend the book Bulletproof AJAX. It's fairly short, well written and describes not only how to use AJAX, using PHP as a programming language, but also how to create pages which take advantage of AJAX but still work OK if the user has JavaScript turned off.

The only difference in what I do when I'm returning JavaScript or HTML to a browser for AJAX is to not output the headers or any extra data. (The error handling I use outputs errors when in debug, so I have disable this as well.)

Yes, PHP can output XML and JSON for Ajax but not all PHP frameworks support JSON/XML equally well.

For example: I ran into an problem in Drupal (4.7) where the PHP sessions would be deleted after outputting a JSON response. (The HTML output code was explicitly closing the session, which was required or the session would be erased.)

I would also love know about PHP frameworks that make it easier to manage to javascript code. Even something basic such as including jQuery only on the pages that require it. Or helping to manage minimizing/packing javascript code.

Pardon for posting on the old question, but the relatively new framework Agile Toolkit is the perfect answer to OP.

It allows you to create fully object-oriented Web-GUI without going into HTML/JavaScript.

I would highly recommend you use Cjax Framework 100% PHP Side Ajax Framework.

You will never will you see a line of JavaScript.

Cjax lets you do, ajaxy stuff, most of the time with one single line of code.
Also Cjax integrates into CodeIgniter, like your finger integrates into a ring!

This is a thread in the CodeIgniter forums: http://forum.codeigniter.com/thread-65967.html

Cjax is not exclusive to CodeIgniter as any website or application can use it, but it has built-in support for it.

There is also great deal of documentation: (From CodeIgniter wiki): https://github.com/bcit-ci/CodeIgniter/wiki/ajax-framework-for-codeigniter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top