开发者

PHP framework question

开发者 https://www.devze.com 2022-12-22 01:30 出处:网络
I\'m currently working on a browser-based MMO and have chosen the LAMP stack because of the extremely low cost to start with in production (versus Windows + IIS + ASP.NET/C# + SQL Server, even though

I'm currently working on a browser-based MMO and have chosen the LAMP stack because of the extremely low cost to start with in production (versus Windows + IIS + ASP.NET/C# + SQL Server, even though I have MSDN Universal). However I will need a PHP framework for this as it's no easy task. I am not restricted by anything other than the ability to run on Linux, as I will use a dedicated cloud hosting solution (and a VMWare image for development) and can configure it as needed.

In no specific order:

  1. It has to be easily scalable; this is crucial. If the game becomes a steady success it will eventually outgrow the server beyond what the host provides and would have to be moved to several load-balanced servers. It is crucial that this can be done with minimum effort. I do know this might require following strict conventions, so if you know of any for your suggested framework please explain what would be needed.
  2. It has to provide modules for all the core tasks: authentication, ACL, database access, MVC, and so on. One or two missing modules ar开发者_开发问答e fine, as long as they can easily be written and integrated.
  3. It should support internationalization. I think there is no excuse for any web framework not to provide means of translating the application and switching between languages without a lot of effort from the programmer.
  4. Must have very good community support and preferably commercial support as well. Yes, I do know QCodo/QCubed is so nice, but it is not mature enough for this task.
  5. Smooth AJAX support is required. Whether the framework comes with AJAX-capable widgets or has an easy way of adding AJAX is not relevant, as long as AJAX is easily doable. I plan to use jQuery + Dojo or one of them alone - not exactly sure.
  6. Auto-magically doing stuff when it improves readability and relieves a lot of effort would be especially nice if it is generally reliable and does not interfere with other requirements. This seems to be the case of CakePHP.

I have read a lot of comparisons and I know it's a really hot debate. The general answer is "try and see for yourself what suits you". However, I can't say it is easy for this task and I'm calling for your experience with building applications with similar requirements. So far I'm tied up between Zend and CakePHP by the general criteria, however, all well-known frameworks offer the same functionality in some way or another with different approaches each with it's own advantages and disadvantages.

Edits:

  1. I am kinda new to MVC, however, I am willing to learn it and I don't care if a framework is easier for those new to MVC. I have lots of time to learn MVC and any other architectures (or whatever they're called) you recommend.
  2. I will use Zend as a utility "framework", even though it's just a collection of libraries (some good ones though, as I have been told).
  3. Current PHP contenders are: CakePHP, Kohana, Zend alone.


I see you have looked at Zend and CakePHP, but I would like to point you in a different direction.

http://kohanaphp.org/

Kohana is what I would use if I am was still using PHP. They took CodeIgniter and forked it in a way that makes php feel much less file-based and much more object-based. They have a great templating solution, and also have modules for everything you discussed except for ACL (I don't know what that is so maybe they do have it).

Anyway, I think it is worth checking out.

On Scalability
I noticed some conversation on speed. Although I think Kohana handled things very fast for us, I don't think this as much something to do with the framework as it has to do with other tools.

First I have increased speed on many of my php apps by dropping apache for nginx. Nginx with PHP running as fastcgi is much more light-weight and really increased load times for http://ukclasslist.com. We still use apache locally and the copy running on our server is quicker than our local version.

If you are still having trouble with speed, especially with grabbing large chunks of data you should look into memcache.


I'm pesonally a fan of Kohana. I've CodeIgniter prior to this and Kohana (as I see it) is essentially all the good stuff in CodeIgniter without a lot of the limitations. v3 is the latest version of Kohana and is more robust and flexible than v2.

Performance varies depending on how you're using a framework and its own inherent strengths and weaknesses compared to other frameworks. Your best bet is to use APC (soon to be part of PHP 6) or eAccellerator to cache the compiled PHP scripts.


Scaling is not a problem you can expect a web framework to solve. Even successful MMOs with near-limitless budgets have resorted to sharding and instancing. The best approach is to design your application to be modular. As the need arises, you can move major functions to separate servers. Chat, inventory, and auctions are largely independent features and need not be hosted on the same server, for example. To prevent certain gameplay exploits, you will need a messaging service between your servers, and none of the major web frameworks provide this.

The Achilles' heel in PHP web frameworks is the lack of persistent memory. CakePHP is so slow because the entire web framework must re-initialize for every request. Opcode caches like APC only eliminate the need to parse PHP source files.

I would strongly suggest that you consider web frameworks in other languages. Python, Ruby, and Java are all excellent choices. All of these languages will run on inexpensive Linux servers and don't suffer from the above limitation.


Try Agavi. Simply the best PHP framework out there. Got everything you need and you may just extend, configure or change implementation of core classes via factory.

Freely definable environments (development, staging, production etc.), contexts (Web, SOAP, Console etc.), output types (custom set of renderers with layouts/layers/slots/parameters/HTTP headers) like HTML, JSON, PDF or $WHATEVER and simply the best routing system.

Uses XML for configuration and actually makes USE of it with parent files, schema validation and XIncludes. Nice input validation system with strict validation being the default (and not only for GET/POST, but all other inputs like headers, files and cookies as well). Add some i18n/i10n niceties and builtin SOAP magic and you have the most flexible and powerful PHP framework available (not "web"-only framework).

A bit short on documentation, but it has the only true MVC implementation in comparison to Kohana, CakePHP, Zend and all those other frameworks...just have a look at it and ask questions on IRC or the user mailing list. After a steep learning curve it's the last time you had a look at other (PHP) frameworks for a long time. :-)


First of all, this is good resource on PHP frameworks:

http://www.phpframeworks.com/

You can get in idea easily as there is good comparison of them there.

Secondly, I would strongly recommend you going through this great tutorial on MVC at phpro.org:

http://www.phpro.org/tutorials/Model-View-Controller-MVC.html


Codeigniter is an amazing framework that has a good community support and can scale well as well. Plus you don't need to have shell access to deploy the application. And the MVC integration makes writing applications really easy.


Actually you can have both CakePHP and Zend Framework in one. Zend framework is a bit closer to a library than anything else. So its not hard to use Zend libraries in Cakephp. The best of both worlds.

here is an example of a component or controller to do it.

Also it sounds like proformance would be very important. you may find this interesting http://avnetlabs.com/php/php-framework-comparison-benchmarks

As for scalability maybe this question can help


Here is a good start point http://phpro.org/tutorials/Model-View-Controller-MVC.html.

0

精彩评论

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