Good php infrastructure for fully ajax based web applications?

I am developing a web application that focuses a lot on ajax. the entire application is on one page, with the exception of streams that are on traditional pages, so they can be indexed.

therefore, I have to have very structured JS codes, and I wonder if they are any frameworks that exist for ajax based applications.

eg. codeigniter, cakephp and the others I read about don't focus on that. they just organize regular php code according to mvc.

the reason my code is starting to be very dirty (especially js code) and I really need some structure here. is there a way to have the same mvc + oop structure in javascript? I have never heard anyone say this. even if I put js codes in separate files, one for each page, there are many lines, and I feel lost and crunching whenever I have to add some new features.

It would be great with suggestions and ideas on how to structure this!

+6
javascript ajax php frameworks
source share
6 answers

I think you have the wrong way of thinking about it.

AJAX-heavy sites or applications are not so different from their Web 1.0 counterparts in their signatures. You still have the same basic components: HTTP requests and responses. It's just that with AJAX, you rarely request a full HTML page. In most cases, you request HTML, XML, or JSON snippets.

So, just because you have a website / application that works 90% + AJAX does not mean that you need to throw away existing conventions like MVC and look for something new.

And in most modern frameworks there are many AJAX things baked in: ZF, symfony, cake, etc.

EDIT

I do not know any frameworks, PHP or JavaScript oriented to what you ask. In doing so, you can get something from viewing High-Performance JavaScript: why everything that you knew was wrong , "Developing rich web experience" and high-performance Ajax applications , although they are already a couple of years old.

Also, consider digging into projects that are heavy on AJAX and see how they are ticking. ExtJS and jQuery frontend applications are a good start.

+4
source share

You can check out Zephyr . Never used it myself, I just know that this is mainly for AJAX applications.

+1
source share

Symfony's framework is great for Ajax, and they have a well-thought-out approach using the MVC server and your JavaScript code, especially the popular JavaScript libraries such as JQuery and Scriptaculous.

It would be interesting to read the chapter of the Ajax chapter in the Symfony Askeet tutorial to see how someone did this. In addition, the Ajax chapter in the old symfony book describes other features besides the autocomplete search feature shown in the Askeet tutorial.

+1
source share

Check out the Yii or Zend Framework .

0
source share

I create such applications. My architecture:

  • Server Side: Zend Framework
    PHP code is presented as a set of JSON-RPC web services. Web services are implemented using Zend_Json_Server and do not generate HTML (all user interfaces are processed on the client side). Because of this, server code is rather limited (interacting with databases, session management, and security).
  • Client side: ExtJS
    The code is loaded from a single PHP page hosting the ExtJS framework, and then dynamically loads the JavaScript components as separate files on request. Each javascript component calls a web service to initialize and load / save data. There are also special translation files (dynamically generated from PHP) for fixing prototypes of a class with translations.

In this approach, web services do not send back any pre-generated HTML. They are data bridges, moving records back and forth. All user interface building is done on the client side. Zend_Json_Server provides the PHP class as a service (class methods are functions of the service). This simplifies PHP development and provides maximum flexibility in the user interface. The mobile interface is built around the same classes as the RIA interface. It is also easy to create other applications on top of the same web services (e.g. Windows application, iphone application, ...). A minimal amount of PHP code reduces server overhead.

If I were you, I would focus more on what kind of javascript framework you are using than on the PHP framework. If you are going to use ajax as a whole (without the basic back-back-html), it just doesn't make sense to involve the server in creating the user interface (it just slows down the application).

0
source share

Do you want something special for ajax that can integrate into other structures? try, Cjax: http://cjax.sourceforge.net/examples/ , good for heavy ajax, with ajax controllers and routes.

I was told to add more details, so this is happening ...

This allows you to write ajax on the PHP side, it gives you many tools that you can use to make your development smooth. It also saves you a ton of time from re-creating the wheel.

Cjax comes with over 70 examples / samples / documents and APIs that can let you do amazing things with a single line of code, which otherwise will take you hours or days or even weeks !. You know, the usual success message, lightbox, submitting forms using ajax and uploading files using ajax, you know - the usual things that you would use in your application or website are the e-cosystem functions of ajax.

Cjax combines all your ajax codes in one place. Securing your code. Cjax also has only one access point. Securing your application or website. Cjax allows you to use classes and route your ajax calls through the dispatcher to reach your ajax controller. It includes a callback system that allows you to execute ajax requests when the page loads, and also when you run your ajax request once on the server, it allows you to run more ajax code and interact with your application or website directly from the back, end, directly from your controller. This gives you the freedom to go back and forth, from one ajax method to another, working in harmony. It also includes a way in which you can maninupate all the elements on the page, right from the inside, all done in one ajax call.

Cjax is a tool for creating ajax functions. Uses unconventional methods to push bounderies, allowing you to simply write very few short lines of code.

Cjax has the right to allow you to call and use your existing JavaScript without making any changes to it. It really allows you to express yourself the way you want to express. If you have old or new custom JavaScript, execute it using Cjax - you can transfer data to your existing functions, run them directly from the background. You use other third-party libraries or code - no problem. Cjax allows you to execute it and transfer data to it directly from the background space, you can call them as many times as you want, without restrictions, only the sky. You can go from simple strings or integers to whole arrays or objects. Guess that, in fact, these are Cjax plugins, "plugins" are just a formality, but what they really are - custom code works with Cjax. If you run your own code, you have already created the Cjax plugin!

Cjax code is easy to understand and uses a configuration-based approach to make the most of it, with less.

I will give some examples: Pagination: http://cjax.sourceforge.net/examples/pagination.php autocomplete, ajax loader, etc.

0
source share

All Articles