_php techniques for problems existing in common PHP frameworks such as ZF
Source: Internet
Author: User
Starting with the Zend Framework v0.13 version, I started learning to use the Zend Framework. At that time, a company project also happened to use the Zend Framework. After the 0.6 version, there is no more attention to detail. Some days ago I heard that Zend Company will formally launch the Zend Framework in May, and today the students have been specially asked to download the test.
The latest version is 0.93, and the test finds that the ZF framework is becoming more and more fool-made. Many things are directly encapsulated in the ZF library. You just know how to call on OK pull. And the previous version in detail does have a larger change, but also increased the comparison of multi-functional.
First of all, zend.php disappeared, replaced by a zend_load class, put in load.php inside.
Second, the Library class loading more convenient. The previous ZF would be more troublesome to use in subdirectories. Now it can be used directly in subdirectories, and can now be used without mod_rewrite, and can be accessed through http://path/to/site/controller/action, similar to some of my questions on the answer Phpchina: URL mapping refers to the URL mapping.
Third, the attempt to directly integrate into the controller inside, convenient to call. But there is a bad place to regulate the directory structure of the program according to ZF's requirements.
Also added a lot of features, such as access control and so on. In a word, it changes a lot. I just looked at it tonight.
For zf,cakephp and so on frame, I think everybody in the study time best can understand the basic principle of the frame, the so-called "change is not away from it". The framework itself is very simple, there is no ZF and so on such as complex, they are only the details of the processing is perfect, at the same time to achieve universal, normative, powerful, so complex. On the fundamentals of the framework, I recommend that you read an article on phpit.net about how to use PHP5 to build a simple MVC framework (there are translations on the Joy International Village), or look at one of my articles, "the easiest way to implement MVC in PHP" series.
There was a post on Chinaunix that discussed the advantages and disadvantages of using objects and processes in PHP projects, and the discussion was very good. There are support objects, but also think that the development of the object is more in line with the characteristics of web development, have better performance.
I personally support object-oriented development, especially in PHP5 environments (because PHP5 objects and PHP4 objects are not the same thing, see the Zend Engine). But the points in the post are also very reasonable: "OOP in the form of no reason to load a lot of unrelated functions." Web development is very performance-focused, and PHP is an interpretive language, and if you include too many code, it's very performance-impacting. This problem exists both in Zend framework,cackephp,fleaphp and in my framework Phpbean.
For example, a Indexcontroller, where the Zend Framework is used as an example. The code is as follows:
?
Class Indexcontroller extends Zend_controller_action {
For example, when we visit Index/index, the contents of the Testaction () and Showaction () methods are completely redundant. In the actual development in accordance with this idea, is generally a functional module corresponding to a controller, for example, the user corresponds to a usercontroller, and then there are login, exit, registration, list, detailed display and so on a variety of methods. When a project is large, a controller may be a few k to more than 10 K. That's a very bad model.
In the Java struts, there is a completely different way, he is an action corresponding to a file. I think this is a very good reference method.
I think PHP5 words, use face object more when. It can be said that the face of the process can be achieved, the face of the object can be achieved, and can achieve better. But the important point is: using the face of the object of thinking to use the face of the object, rather than face the process of thinking to write the face of the object of the program!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service