Zend Framework is an open source PHP development framework based entirely on PHP5 developed by Zend Company. It can be used to develop Web programs and services. It uses the MVC (Model-View-Controller) architectural pattern to separate different parts of the application to facilitate program development and maintain.
ZF2 is not just a patchy update like other frameworks. Instead, it completely rewrites all the code of ZF1. The main slogan is "high performance".
Let’s take a look at what new features ZF2 has brought:
1. Modularization (ModuleManager)
Compared with ZF1, ZF2 natively supports the concept of modules. Any third-party PHP program can be turned into a Zend module as long as it follows Zend's coding standards and code structure. At present, a batch of experimental modules have been released (see ZF2 Modules). There are many excellent projects like Doctrine ORM.
It is foreseeable that as ZF2 slowly matures, more and more optional modules will emerge. It is possible that future project development based on ZF2 will be as easy and simple as building blocks.
2. Event driven (EventManager)
In traditional programs, codes are executed in a linear sequence, so it is often difficult to separate some functions into a component or module during development.
Event-driven, or hook, changes the way ordinary programs run in a streamlined manner. After applying event-driven, the program will run in a jump-like manner of "registered event" => "triggered event", which can be run without affecting With the original program code, it is easy to add new business logic at any location, making project development extremely flexible.
3. ServiceManager
The concept of service manager comes from the programming idea of "Service locator pattern". This idea advocates extracting each independent function in the program as a "service". Each service is independently wakeable. Only when the service is called, the service-related program will be started.
This is the secret of ZF2's performance improvement. The idea of ServiceLocator is everywhere reflected in ZF2's MVC startup process. The calls to function modules are extremely "stingy", which will surely come as a big surprise to developers who have previously had issues with Zend's performance.
4. Dependency Injection
Dependency injection is widely used in mainstream Java frameworks and can effectively decouple large-scale applications. The introduction of Di into ZF2 has gone through repeated considerations and trade-offs. Even after entering the beta stage, Di was still used as the basic implementation solution for ZF2, and the entire Mvc configuration was based on Di. In the end, in order to avoid falling into the metadata programming quagmire (Metaprogramming) that Di may cause, Di is only used as the bottom implementation of ZF2, and ServiceManager is added to the upper layer. Ordinary developers do not need to be exposed to the Di level when using ZF2. However, this does not prevent DI from existing and functioning as an excellent PHP component.
5. Social programming
The code of ZF2 is completely hosted on Github. With the excellent design of Github, anyone can easily participate in the ZF2 project construction through fork, and even submit new module functions. The author AlloVince also helped the Zend team fix some bugs and found that the Zend team responded very quickly (never more than 24 hours) and took the time to answer feedback seriously. Therefore, participating in the ZF2 project is a good choice for participating in the PHP open source project.