Yaf Framework's extended-mvc-routing configuration-template view Smarty loading

Source: Internet
Author: User
Tags php framework smarty template

YAF (yet another framework) (another framework (own understanding))

(excerpt) YAF advantages:

1. The PHP framework, developed in C, provides little additional performance overhead compared to native PHP.
2. All framework classes, do not need to compile, load at PHP startup, and resident memory.
3. Shorter memory turnaround cycle, improve memory utilization, reduce memory usage.
4. Smart Auto-loading. It supports both global and local load rules, and facilitates the sharing of class libraries.
5. High-performance view engine.
6. A highly flexible and extensible framework that supports custom view engines, supports plug-ins, supports custom routing, and more.
7. Built-in various routes, can be compatible with the current common routing protocols.
8. Powerful and highly flexible configuration file support. The cache configuration file is supported to avoid the performance loss caused by complex configuration structure.
9. In the framework itself, the dangerous operating habits are prohibited.
10. Faster execution speed and less memory footprint.

As expected, the performance of YAF is really very high, almost no additional performance overhead, it is worthwhile to use the framework, the following on my own learning to illustrate the next yaf corresponding knowledge points:

1:MVC mode:

YAF provides the most basic MVC pattern with the following flowchart:

This is YAF all the flowchart, it is clear that YAF processing request process.

2: Plugins

YAF provides plug-in functionality to provide us with the extension of the space left, to define the plugin will inherit Yaf_plugin_abstract, while it has 6 hooks

Trigger Order name Trigger Time Description
1 Routerstartup Triggered before routing This is the first of 7 events. But some of the global custom work, or should be put in the bootstrap to complete
2 Routershutdown Trigger after route ends The route must be completed correctly at this point, otherwise this event will not trigger
3 Dispatchloopstartup Triggered before the distribution loop is started
4 Predispatch Triggered before distribution If forward occurs during a request processing, the event is triggered multiple times
5 Postdispatch Triggered after distribution ends At this point the action is finished and the view is rendered. Similar to Predispatch, this event may also trigger multiple
6 Dispatchloopshutdown Triggered after the distribution loop has ended This indicates that all business logic has been completed, but the response has not yet been sent

You can add your own extensions where you want to work, and then register your search on the route.

3: Routing

YAF routing has been able to meet most of the functional needs, the application of the central component is composed of routing and routing protocols, routing only one routing protocol can have a lot, you can define your own route according to your own needs, the most used is Yaf_route_regex is routing He is able to complete the route you want below is the route that you define according to your project:

Be careful when you want to use multiple modules when you want to Application.modules = Index, shop plus your own defined modules

At the same time in the regular route to indicate that you want to route the large module below is to indicate the module name: Routes.regex_index.route.module = Shop

4:bootstarp

Bootstrap, also known as the Boot program. It is a global configuration portal provided by YAF, and in bootstrap you can do a lot of global customization work.

All methods defined in the Bootstrap class, beginning with _init, are called sequentially, and these methods can accept an Yaf_Dispatcher instance as a parameter.

5: Database

YAF does not provide inheritance about the database this needs to expand its own database according to its own needs, and you can also load the database classes in Zendframwork, the directory structure of my database is:

Then you can inherit your own database extension to improve your development efficiency.

6:smarty

YAF provides a view load is not so good and in order to be compatible with the previous project I joined the smarty template

Add smary template in Yaf is very headache is smarty file directory structure and YAF automatically loaded directory is not the same will cause the file can not be loaded, this problem I have been resolved in my blog.

Yaf can say one of the most lightweight frames he offers you to expand your space.

I am the directory structure of my entire project as follows:

Yaf Framework's extended-mvc-routing configuration-template view Smarty loading

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.