I am running a site about PHP Frameworks, but I can't find a exact definition for it, and I am always thinking a question, how to make out a good PHP framework? Features? Manual? Efficiency? Or something?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
A PHP Framework in my eyes is a collection of classes which help you develop a web application.
In my company we use the Zend Framework. I have to say that getting started with this Framework is pretty hard, but if you get how to use the API and the Reference Guide you have a great Framework. Also its interessting because they have Zend people sitting on the project so they can use those internal tricks and get some performance boosts others can't get.
What also differs ZF from others is the ability to create MVC programms with no big hassles.
Essentially a framework is the structure that you can choose to build your program on. It can allow you to connect to many different API's as well as determine the structure of your own application. I use the Zend Framework. It's not the easiest to learn, but certainly has everything you need for a great application. I would suggest going through the QuickStart guide on the site to get the ball rolling with this. It uses Model-View-Controller which is essential in my opinion. Once you have it configured, it makes things extremely easier!
Other frameworks include CodeIgniter and Symfony. Some like CodeIgniter for its smaller footprint. It's all a matter of preference. Whichever you pick be sure to use the documentation on the sites as it is essential to understanding how best to use it. Also, don't be scared to peak at the code every once in a while just to get a better understanding of how things work.
Frameworks provide scaffolding that can allow you to develop faster/more cleanly. They often provide toolsets for both the UI components and the underlying database access.
For (very) small projects, a framework can be overkill, but often, it's helpful to provide you with a lot of reusable code.
Some notable frameworks for PHP : Zend Framework CodeIgniter Symfony CakePHP Mojavi
A comparison chart. A more detailed review site.
PHP framework is a library that makes the life of site developer easier by for example hiding some complexities of HTTP protocol or by adding some useful functions. For example the CakePHP implements so called MVC which makes developer to think a level higher than HTTP. This is what I have learned so far.
Asking a programming forum what is a good framework is like asking a car forum what is a good car. The opinions vary wildly, and in 95% of cases, it really doesn't matter what you choose, as long as it's actively developed. Most of your replies will be based on religion and not subjective comparisons. :)
There's a lot to be said for frameworks - and good posts here. However be aware that they are not always the best solution. Reasons you might prefer to avoid them are
Because of the codebase size they tend to be slow (I've seen figures of 10 times slower simple PHP embedded page delivery quoted for Zend for example - admittedly one of the larger ones).
They can be inflexible outside the 'domain' they are intended to work with. Extending a framework to do something that is non-standard can be much more difficult than just coding from scratch.
Some sacrifice of modularity is required. The advantage of using a more simple template/control file system (such as TinyButStrong) is that each page is a distinct unit, which naturally tends to make your system easier to unit test and robust.
They tend to be vulnerable to version control issues. It's all very well and good developing your first one, but after you have a dozen or so websites developed you'll most likely find you've been using three or four release versions of the framework and you have a mish-mash of codebases to work with - and syncing everything takes time you probably won't have.
None of the above are conclusive arguments against using a framework, in many (most?) cases the advantages will score more highly, but you should not be reaching for one without first considering what your requirements are and what is the best solution for each particular problem.