开发者

good php framework for fully ajax-based web applications? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

开发者_StackOverflow中文版 Improve this question

i'm developing a web application that focus heavily on ajax. the whole application is just on one page except for the threads that are in traditional pages so they can be indexed.

so i have to have very structured JS-codes and i wonder if they are any frameworks out there that are for ajax-based applications.

eg. codeigniter, cakephp and others i have read about dont focus on this. they just organize regular php code according to mvc.

cause my code starts to be very messy (especially the js code) and i really need some structure here. is there a way to have same mvc + oop structure in javascript? i never heard anyone talking about it. even if i put js codes in separate files, one for each page for example, there are a lot of lines and i feel lost and crunch whenever i have to add some new functionalities.

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


I think you have the wrong mindset about this.

AJAX-heavy sites or applications aren't that much different form their Web 1.0 counterparts in their underpinnings. You still have the same basic components: HTTP Requests and responses. It's just that with AJAX you rarely request a full HTML page. Most of the time you're requesting snippets of HTML, XML, or JSON.

So, just because you'll have a web site/app that is 90%+ AJAX driven doesn't mean you need to throw away existing conventions like MVC and look for something new.

And most modern frameworks have plenty of AJAX stuff baked in: ZF, symfony, cake, etc.

EDIT

I don't know of any framework, PHP or JavaScript, geared towards what you are asking. That being said, you might get something out of watching High-performance JavaScript: Why Everything You've Been Taught Is Wrong, Designing the Rich Web Experience, and High Performance Ajax Applications, even though they're a couple years old now.

Also, consider digging into projects that are AJAX heavy and seeing how they tick. ExtJS and jQuery UI based applications would be a good start.


You might check out Zephyr. Never used it myself, I just know that it's mainly for AJAX apps.


The symfony framework is great for Ajax, and they have a well-thought-out approach involving the MVC backend and your JavaScript code, especially the popular JavaScript libraries like JQuery and Scriptaculous.

It would be worth your time to read the chapter on Ajax in the Symfony Askeet tutorial just to see how someone else has done it. Also, the Ajax chapter in the older symfony book outlines other uses besides the search autocomplete feature shown in the Askeet tutorial.


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

I was told to put in more details so here it goes...

It allows you to write ajax in the PHP side, it gives you many tools that you can use to make your development experience a smooth ride. It also saves you tons of time from re-inventing the wheel

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

Cjax consolidates all your ajax code in a single place. Making your code more secure. Cjax also has only one point of access. Making your application or website very secure. Cjax lets you use classes and routes your ajax calls through a dispatcher to reach your ajax controller. Includes a callback system, that lets you do ajax requests when the page loads, but also, when you trigger your ajax request once on the server, it lets you run more ajax code, and interact with your application or website right from the back-end, right from your controller. This gives you the freedom to go back and forth, from one ajax method to the other, working in harmony. Also includes a way that you can maninupate all the elements on the page, right from the back-end, all done within one ajax call.

Cjax is a piece of machinery to build ajax features . Uses unconventional methods to push the bounderies in allowing you to just write very few short lines of code .

Cjax has the power to allow you to to call and use your existing JavaScript, without making changes to it. It really lets express yourself in the way that you want to express. You have old, or new custom JavaScript, execute it with Cjax - you can pass data to your existing functions, instanciate them, right from the back-end. You use other 3rd party libraries or code - no problem. Cjax lets you execute it, and pass data to it, right from the back-end, you can call them as many times as you want, no limit, only the sky. You can pass from simple strings, or integers, to entire arrays or objects. Guess what, As a matter of fact, that is what Cjax's plugins are, 'plugins' is just a formality, but what they really are - custom code ran with Cjax. If you run your custom code, you already built a Cjax plugin!

Cjax code is simple easy to understand, and uses convention over configuration approach to do the most, with less.

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


Check out Yii or Zend Framework.


I build apps like these. My architecture:

  • Server-side: Zend Framework
    The PHP code is exposed as a set of JSON-RPC web services. The web services are implemented with Zend_Json_Server, and don't do anything HTML generation (all UI is handled client-side). Because of this, the server-side code is fairly limited (database interaction, session management, and security).
  • Client-side: ExtJS
    The code is bootstrapped from a single PHP page hosting the ExtJS framework, and after that dynamically loads javascript components as separate files on-demand. Each javascript component calls a web service to initialize itself and load/save data. There are also special translation files (dynamically generated from PHP) to patch the class prototypes with translations.

In this approach the web services do not send back any sort of pre-generated HTML. They are data bridges, shuttling records back and forth. All UI construction is done client-side. Zend_Json_Server exposes a PHP class as a service (the methods of the class are the functions of the service). This keeps the PHP design clean, and offers ultimate flexibility in UI. The mobile front-end is built around the same classes as the RIA front-end. It's also easy to build other apps on top of the same web services (e.g. a windows app, an iphone app, ...). The minimal amount of PHP code keeps server overhead low.

If I were you I would focus more on what javascript framework you're using than on a PHP framework. If you're going whole-hog ajax (without basic html fallback), there's simply no point in getting the server involved in generating the UI (it just slows the app down).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜