mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Add Yaf application configuration chapter
and some relevant changes git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@320263 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
84f0c18eb0
commit
de37812124
6 changed files with 333 additions and 7 deletions
315
reference/yaf/appconfig.xml
Normal file
315
reference/yaf/appconfig.xml
Normal file
|
@ -0,0 +1,315 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 319958 $ -->
|
||||
|
||||
<chapter xml:id="yaf.appconfig" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title xmlns="http://docbook.org/ns/docbook">Application Configuration</title>
|
||||
<para>
|
||||
You should give an array of config or an ini config file(see
|
||||
<classname>Yaf_Config_Ini</classname> path to
|
||||
<methodname>Yaf_Application::__construct</methodname>.
|
||||
</para>
|
||||
<para>
|
||||
Yaf configurations could be merged with user configurations. The difference
|
||||
is, Yaf configurations are prefixed with "yaf." or "application.", if there
|
||||
are both "yaf." and "application.", "application." will be accepcted
|
||||
preferentially.
|
||||
<example>
|
||||
<title>An array of yaf configuration example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$configs = array(
|
||||
"application" => array(
|
||||
"directory" => dirname(__FILE__),
|
||||
"dispatcher" => array(
|
||||
"catchException" => 0,
|
||||
),
|
||||
"view" => array(
|
||||
"ext" => "phtml",
|
||||
),
|
||||
),
|
||||
);
|
||||
$app = new Yaf_Application($config);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>an ini file of yaf configuration example</title>
|
||||
<programlisting role="ini">
|
||||
<![CDATA[
|
||||
[yaf]
|
||||
yaf.directory = APPLICATION_PATH "/appliation"
|
||||
yaf.dispatcher.catchException = 0
|
||||
|
||||
[product : yaf]
|
||||
; user configuartions list here
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<table>
|
||||
<title>Yaf Application Config</title>
|
||||
<tgroup cols="3">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>&Name;</entry>
|
||||
<entry>&Default;</entry>
|
||||
<entry>&Changelog;</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>application.directory</entry>
|
||||
<entry></entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.ext</entry>
|
||||
<entry>"php"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.view.ext</entry>
|
||||
<entry>"phtml"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.modules</entry>
|
||||
<entry>"index"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.library</entry>
|
||||
<entry>application.directory . "/library"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.bootstrap</entry>
|
||||
<entry>application.directory . "/Bootstrap" . application.ext</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.baseUri</entry>
|
||||
<entry>""</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.dispatcher.throwException</entry>
|
||||
<entry>1</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.dispatcher.catchException</entry>
|
||||
<entry>0</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.dispatcher.defaultModule</entry>
|
||||
<entry>"index"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.dispatcher.defaultController</entry>
|
||||
<entry>"index"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>application.dispatcher.defaultAction</entry>
|
||||
<entry>"index"</entry>
|
||||
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
|
||||
&ini.descriptions.title;
|
||||
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry xml:id="configuration.yaf.directory">
|
||||
<term>
|
||||
<parameter>application.directory</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The directory of the application, that is the folder which contains the
|
||||
"controllers", "views", "models", "plugins" folders.
|
||||
</para>
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
This config entry is the only one which doesn't has a default value, which means you should
|
||||
always define it.
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.ext">
|
||||
<term>
|
||||
<parameter>application.ext</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The file ext of the PHP script, used in class autoloading(
|
||||
<classname>Yaf_Loader</classname>).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.view.ext">
|
||||
<term>
|
||||
<parameter>application.view.ext</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The file ext of the view template script.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.modules">
|
||||
<term>
|
||||
<parameter>application.modules</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
A commaseparated list of the registered modules, used in the route
|
||||
process, especially while there are more than three segments in the PATH_INFO,
|
||||
</para>
|
||||
<para>
|
||||
Yaf need a way to find out whether the first segment is a module name or not.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.library">
|
||||
<term>
|
||||
<parameter>application.library</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The local library directory, see <classname>Yaf_Loader</classname> and
|
||||
<link linkend="ini.yaf.library">yaf.library</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.bootstrap">
|
||||
<term>
|
||||
<parameter>application.bootstrap</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
A absolute path of the Bootstrap class script.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.baseUri">
|
||||
<term>
|
||||
<parameter>application.baseUri</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Used to remove a fixed prefix of request uri in route process.
|
||||
Take a example, comes a request with request uri
|
||||
"/prefix/controller/action". if you set application.baseUri to
|
||||
"/prefix", then only "/controller/action" will take as the PATH_INFO in
|
||||
route process.
|
||||
</para>
|
||||
<para>
|
||||
In generally, you have no need to set this value.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.dispatcher.throwexception">
|
||||
<term>
|
||||
<parameter>application.dispatcher.throwException</parameter>
|
||||
<type>bool</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
If this is On, Yaf will throw exception while some error occurring. see
|
||||
also <methodname>Yaf_Dispatcher::throwException</methodname>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.dispatcher.catchexception">
|
||||
<term>
|
||||
<parameter>application.dispatcher.catchException</parameter>
|
||||
<type>bool</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
If this is On, Yaf will forward to Error controller, Error Action while
|
||||
there is a uncaught exception. see also
|
||||
<methodname>Yaf_Dispatcher::catchException</methodname>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.dispatcher.defaultmodule">
|
||||
<term>
|
||||
<parameter>application.dispatcher.defaultModule</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The default module name, see also
|
||||
<methodname>Yaf_Dispatcher::setDefaultModule</methodname>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.dispatcher.defaultcontroller">
|
||||
<term>
|
||||
<parameter>application.dispatcher.defaultController</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The default controller name, see also
|
||||
<methodname>Yaf_Dispatcher::setDefaultController</methodname>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="configuration.yaf.dispatcher.defaultaction">
|
||||
<term>
|
||||
<parameter>application.dispatcher.defaultAction</parameter>
|
||||
<type>string</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The default action name, see also
|
||||
<methodname>Yaf_Dispatcher::setDefaultAction</methodname>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</para>
|
||||
</chapter>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
|
@ -16,11 +16,16 @@
|
|||
Yaf require PHP version greater than 5.2.1, and could not run with early
|
||||
version of PHP.
|
||||
</para>
|
||||
<para>
|
||||
A simple Yaf performance benchmarks can be found at <link
|
||||
xlink:href="&url.yaf.benchmarks;">Yaf Performance</link>.
|
||||
</para>
|
||||
</preface>
|
||||
|
||||
&reference.yaf.setup;
|
||||
&reference.yaf.constants;
|
||||
&reference.yaf.examples;
|
||||
&reference.yaf.appconfig;
|
||||
&reference.yaf.yaf-application;
|
||||
&reference.yaf.yaf-bootstrap-abstract;
|
||||
&reference.yaf.yaf-dispatcher;
|
||||
|
|
|
@ -46,11 +46,15 @@
|
|||
If you want <classname>Yaf_Loader</classname> search some
|
||||
classes(libraries) in the <link linkend="yaf-loader.props.library">local class
|
||||
directory</link>(which is defined in application.ini, and by default,
|
||||
it is APPLICATION_PATH . "/libraray"), you should register the class prefix using the
|
||||
it is <link
|
||||
linkend="configuration.yaf.directory">application.directory</link> . "/libraray"),
|
||||
you should register the class prefix using the
|
||||
<methodname>Yaf_Loader::registerLocalNameSpace</methodname>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Let's see some examples(assuming APPLICATION_PATH is <link
|
||||
linkend="configuration.yaf.directory">application.directory</link>):
|
||||
<example>
|
||||
<title>Config example</title>
|
||||
<programlisting role="shell">
|
||||
|
@ -235,8 +239,9 @@ class A_B_TestModel =>
|
|||
<term><varname>_library</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
By default, this value is APPLICATION_PATH . "/library", you can change
|
||||
this either in the application.ini(application.library) or call to
|
||||
By default, this value is <link
|
||||
linkend="configuration.yaf.directory">application.directory</link> . "/library",
|
||||
you can change this either in the application.ini(application.library) or call to
|
||||
<methodname>Yaf_Loader::setLibraryPath</methodname>
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -54,9 +54,9 @@
|
|||
class Bootstrap extends Yaf_Bootstrap_Abstract{
|
||||
public function _initPlugin(Yaf_Dispatcher $dispatcher) {
|
||||
/**
|
||||
* Yaf assumes plugin scripts under APPLICATION_PATH . "/plugins"
|
||||
* Yaf assumes plugin scripts under [application.directory] . "/plugins"
|
||||
* for this case, it will be:
|
||||
* APPLICATION_PATH . "/plugins/" . "User.php"
|
||||
* [application.directory] . "/plugins/" . "User" . [application.ext]
|
||||
*/
|
||||
$user = new UserPlugin();
|
||||
$dispatcher->registerPlugin($user);
|
||||
|
|
|
@ -84,7 +84,8 @@ class Bootstrap extends Yaf_Bootstrap_Abstract{
|
|||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>plugin Dummy.php (under APPLICATION_PATH/plugins)</title>
|
||||
<title>plugin Dummy.php (under <link
|
||||
linkend="configuration.yaf.directory">application.directory</link>/plugins)</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<para>
|
||||
A absolute path to the template directory, by default,
|
||||
<classname>Yaf_Dispatcher</classname> use
|
||||
APPLICATION_PATH . "/views" as this paramter.
|
||||
<link linkend="configuration.yaf.directory">application.directory</link> . "/views" as this paramter.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
Loading…
Reference in a new issue