PHP Framework YAF Learning notes----default behavior
YAF is a C language-written PHP framework, in the form of PHP extensions. is laruence (brother Bird)? 's Works
Laruence is a member of the PHP development team, PECL developers. YAF, taint and other pecl extension authors.
YAF related articles http://www.laruence.com/tag/yaf?? Online Brochure
The online handbook system is a complete description of everything YAF, here as a guide to learning, listing the default behavior of YAF (contract)
0.YAF configuration file (php.ini style)
In fact, in two parts, one is the configuration "Yaf." In PHP.ini, this part is usually not adjusted.
The other part is the configuration "application." At the Yaf_application initialization time.
?
Configuration can introduce PHP constant definitions
1.YAF must be configured, is actually a directory setting
Yaf.directory=app_pathapplication.directory=app_path
That is, the Appliction script directory, at least one to define, Application.directory first
2.YAF A complete directory organization, file naming rules
All YAF applications should follow the following directory organization structure
-index.php//Entry file-. htaccess/Rewrite rules + conf |-application.ini//profile application/ + Controllers - index.php//Default controller + views |+ index //Controller -index.phtml//default view + modules//other modules -Library -Models //model directory -plugins//Plugin Directory
?
YAF supports case sensitive and insensitive, but I don't find case sensitive usage (Linux environment)
Class naming and search rules
Class name???????????? corresponding directory
Classmodel????? Models
Classplugin????? Plugins
Classcontroller Controllers
Other??????????????? Library
3.YAF is done by using the class name that contains the delimiter "_" with the directory organization, and complete class naming rules to complete the class load management
For example, before you have a bar class file bar.php, if used in Yaf, and automatically loaded, then it is necessary to organize
Put the bar.php in a subdirectory under the library directory, such as MyClass
and to change the class name inside the bar.php (which is generally Bar) to Myclass_bar
That is, the class name must contain a directory name specifically explained
4. Error handling
YAF inside error handling can be done via a controller, declared in app_path/controllers/error.php
Of course the error controller is affected by the configuration
Application.dispatcher.throwexception=1application.dispatcher.catchexception=1
See the examples provided by the official
5. Views View
The render view needs to specify the view template file, either with a relative (application/views) path or an absolute path
6. Routing
YAF provides multiple levels of path support, regular routing is also supported, you can write routes with configuration files, or write routes in bootstrap.php with PHP scripts
One of the most attractive places for a person to think of YAF is:
PHP Framework in PHP extension, if there is no database access bottleneck caused by the cask effect, yaf this form is optimal
Memory usage in some level of application after using YAF should be reduced a lot
?
7.BUG. The following problem is found, do not know whether it is a BUG
YAF does not exactly match the name when it matches the section of the configuration file, such as the configuration
[Product] ...
New Yaf_application ("Conf/app.ini", ' P ')//can still be matched to
?
8.MVC
YAF, like most frameworks, provides a default MVC behavior, and for M (setdefaultmodule) I don't find a way to change the effect.
C and V are one by one corresponding, of course, can be named different, can be set by Yaf_dispatcher's Setview method.
?
9. Single-Case mode class, YAF
Yaf_application
Yaf_loader
Yaf_dispatcher
Yaf_registry
Yaf_session
Class Instances are singleton, others are not
Note that if you use forward in the Yaf_controller_abstract inheriting class action, it will result in a new instance object.
?
10. Non-nested dispatcher (below 2.x version)
YAF The processing of the request is non-nested, which means that all the Controller transfer is non-nested, if a controller is not completed, the transfer occurs, it is possible to have an unknown result or even error, YAF provides forward is waiting for the current controller to be executed before processing, so if the request is processed exactly as MVC, the effect of nesting is achieved, and you need to implement the code yourself. Process Correspondence Description
Mainloopstart Dispatchloopstartup predispatch//is actually a loop controlled by forward This request cannot send a change, can be forward but will be deferred execution Postdispatch forward request deferred execution, loop to Predispatch Dispatchloopshutdown can dispatch a new request, Will start a new dispatchloopstartupmainloopend.
?
?