CakeFest 2024: The Official CakePHP Conference

运行时配置

这些函数的行为受 php.ini 中的设置影响。

Yaf 配置选项
名字 默认 可修改范围 更新日志
yaf.library   INI_ALL
yaf.action_prefer 0 INI_ALL
yaf.lowcase_path 0 INI_ALL
yaf.use_spl_autoload 0 INI_ALL
yaf.forward_limit 5 INI_ALL
yaf.name_suffix 1 INI_ALL
yaf.name_separator   INI_ALL
yaf.cache_config 0 INI_SYSTEM
yaf.environ product INI_SYSTEM
yaf.use_namespace 0 INI_SYSTEM

这是配置指令的简短说明。

yaf.library string

全局库路径,Yaf_loader 会在此目录下搜索全局库。

yaf.action_prefer int

If there is only one part in PATH_INFO, should it consider as a controller or action.

如果此配置为 On,将视为 Action 名。

yaf.lowcase_path int

Whether lowercase all the path during the class autoloading.

yaf.use_spl_autoload int

When this value is On, if Yaf_Loader can not find a class, it will return false, then give chance to other auto load function to be called.

When this value is Off, if Yaf_Loader can not find a class, it will return true, and make the class autoloading failed immediately.

注意:

Yaf will register its loader during a instantiation of Yaf_Application, so any other auto loaders which is register before the instantiation will be called before Yaf_Loader::autoload().

When this value is Off(default), Yaf_Loader::autoload() will always return true.

yaf.forward_limit int

The max forward count, default is 5. that means you can have a max value of 5 in the forward stack.

This is a protection for prevent recursive Yaf_Controller_Abstract::forward().

yaf.name_suffix int

When this On, Yaf_Loader will identify a class by it's suffix to decide whether it is a MVC Class.

When this Off, Yaf_Loader will look at the prefix of the class name.

yaf.name_separator string

When this is not empty, Yaf_Loader will identify the class suffix and string value of this.

For example, when this value is "_", Yaf_Loader will take Index_Controller as a Controller Class, IndexController as a normal class.

yaf.cache_config int

If this is On, and in the meantime you are using ini config file as the parameter of Yaf_Application(), the compiling result of the ini config file will be cached in the PHP process.

注意:

Yaf examine the mtime of the ini file, if it was changed since last compiling, Yaf will reload it.

警告

Yaf use the ini file path as the cache entry key, so do use the absolute path in ini file path, otherwise there might be some conflicts if two application use the same relative path of ini config.

yaf.environ string

默认值是“product”,用于 Yaf 获取 ini 配置文件中的配置部分。

That is, if this value is "product", Yaf will use the section named "product" in the ini config file(the first parameter of the Yaf_Application) as the final config of the Yaf_Application.

yaf.use_namespace int

如果值为 On,Yaf 的所有类都将以命名空间样式命名。

例如:

Yaf_Route_Rewrite => \Yaf\Route\Rewrite
Yaf_Request_Http  => \Yaf\Request\Http
        
有个例外,就是像 Yaf_Controller_Abstract 这样的类。最后部分是 PHP 的关键字,不能用作类名,对于这样的类,只能:
Yaf_Controller_Abstract => \Yaf\Controller_Abstract
Yaf_Route_Static => \Yaf\Route_Static
        

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top