mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
update docs
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@319958 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
83a6761c73
commit
e9cc656f17
4 changed files with 127 additions and 31 deletions
|
@ -227,12 +227,12 @@
|
|||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
This value is "dev" by default, used for Yaf to fetch the config
|
||||
This value is "product" by default, used for Yaf to fetch the config
|
||||
section of a ini config file.
|
||||
</para>
|
||||
<para>
|
||||
That is, if this value is "dev", Yaf will use the section named "dev"
|
||||
in the ini config file(the first parameter of the
|
||||
That is, if this value is "product", Yaf will use the section named
|
||||
"product" in the ini config file(the first parameter of the
|
||||
<classname>Yaf_Application</classname>) as the final config of the
|
||||
<classname>Yaf_Application</classname>.
|
||||
</para>
|
||||
|
|
|
@ -36,26 +36,38 @@
|
|||
</para>
|
||||
|
||||
<para>
|
||||
<programlisting role="shell">
|
||||
<example>
|
||||
<title>Config example</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
// Assuming the following configure in php.ini:
|
||||
yaf.libraray = "/global_dir"
|
||||
|
||||
//Assuming the following configure in application.ini
|
||||
application.libraray = APPLICATION_PATH "/library"
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
//Assuming the following local name space registerd:
|
||||
Assuming the following local name space registerd:
|
||||
<example>
|
||||
<title>Register localnamespace</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Bootstrap extends Yaf_Bootstrap_Abstract{
|
||||
public function _initLoader($dispatcher) {
|
||||
Yaf_Loader::getInstance()->registerLocalNameSpace(array("Foo", "Bar"));
|
||||
}
|
||||
public function _initLoader($dispatcher) {
|
||||
Yaf_Loader::getInstance()->registerLocalNameSpace(array("Foo", "Bar"));
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
then the autoload examples:
|
||||
<programlisting role="shell">
|
||||
Then the autoload examples:
|
||||
<example>
|
||||
<title>Load class example</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
class Foo_Bar_Test =>
|
||||
// APPLICATION_PATH/library/Foo/Bar/Test.php
|
||||
|
@ -66,11 +78,13 @@ class GLO_Name =>
|
|||
class BarNon_Test
|
||||
// /global_dir/Barnon/Test.php
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
As of PHP 5.3, you can use namespace, in this case you need open the
|
||||
<link linkend="ini.yaf.use-namespace">yaf.use_namespace</link> on, then:
|
||||
<programlisting role="shell">
|
||||
As of PHP 5.3, you can use namespace:
|
||||
<example>
|
||||
<title>Load namespace class example</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
class \Foo\Bar\Dummy =>
|
||||
// APPLICATION_PATH/library/Foo/Bar/Dummy.php
|
||||
|
@ -78,8 +92,10 @@ class \Foo\Bar\Dummy =>
|
|||
class \FooBar\Bar\Dummy =>
|
||||
// /global_dir/FooBar/Bar/Dummy.php
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You may noticed that all the folder wth the first letter capitalized, you can make them
|
||||
lowercase by set <link linkend="ini.yaf.lowcase-path">yaf.lowcase_path</link> = On in php.ini
|
||||
|
@ -88,23 +104,28 @@ class \FooBar\Bar\Dummy =>
|
|||
<para>
|
||||
<classname>Yaf_Loader</classname> is also designed to load the MVC classes,
|
||||
and the rule is:
|
||||
<programlisting role="shell">
|
||||
<example>
|
||||
<title>MVC class loading example</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
Controller Classes =>
|
||||
// APPLICATION_PATH/controllers/
|
||||
// APPLICATION_PATH/controllers/
|
||||
|
||||
Model Classes =>
|
||||
// APPLICATION_PATH/models/
|
||||
// APPLICATION_PATH/models/
|
||||
|
||||
Plugin Classes =>
|
||||
// APPLICATION_PATH/plugins/
|
||||
// APPLICATION_PATH/plugins/
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
Yaf identify a class's suffix(this is by default, you can also change to
|
||||
the prefix by change the configure <link
|
||||
linkend="ini.yaf.name-suffix">yaf.name_suffix</link>) to decide whether it
|
||||
is a MVC class:
|
||||
<example>
|
||||
<title>MVC class distinctions</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
Controller Classes =>
|
||||
|
@ -117,9 +138,12 @@ Plugin Classes =>
|
|||
// ***Plugin
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
some examples:
|
||||
<programlisting role="shell">
|
||||
<example>
|
||||
<title>MVC loading example</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
class IndexController
|
||||
// APPLICATION_PATH/controllers/Index.php
|
||||
|
@ -133,7 +157,8 @@ class DummyPlugin =>
|
|||
class A_B_TestModel =>
|
||||
// APPLICATION_PATH/models/A/B/Test.php
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
also, the directory will be affected by <link linkend="ini.yaf.lowcase-path">yaf.lowcase_path</link>.
|
||||
</para>
|
||||
|
|
|
@ -27,13 +27,18 @@
|
|||
on Rails routing and does not require any prior knowledge of webserver URL
|
||||
rewriting. It is designed to work with a single Apache mod_rewrite rule
|
||||
(one of):
|
||||
<example>
|
||||
<title>Rewrite rule for Apache</title>
|
||||
<programlisting role="conf">
|
||||
<![CDATA[
|
||||
RewriteEngine on
|
||||
RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ index.php
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
or (preferred):
|
||||
<example>
|
||||
<title>Rewrite rule for Apache</title>
|
||||
<programlisting role="conf">
|
||||
<![CDATA[
|
||||
RewriteEngine On
|
||||
|
@ -44,7 +49,10 @@ RewriteRule ^.*$ - [NC,L]
|
|||
RewriteRule ^.*$ index.php [NC,L]
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
If using Lighttpd, the following rewrite rule is valid:
|
||||
<example>
|
||||
<title>Rewrite rule for Lighttpd</title>
|
||||
<programlisting role="conf">
|
||||
<![CDATA[
|
||||
url.rewrite-once = (
|
||||
|
@ -54,6 +62,25 @@ url.rewrite-once = (
|
|||
)
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
If using Nginx, use the following rewrite rule:
|
||||
<example>
|
||||
<title>Rewrite rule for Nginx</title>
|
||||
<programlisting role="conf">
|
||||
<![CDATA[
|
||||
server {
|
||||
listen ****;
|
||||
server_name yourdomain.com;
|
||||
root document_root;
|
||||
index index.php index.html;
|
||||
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^/(.*) /index.php/$1 last;
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
<!-- }}} -->
|
||||
|
@ -67,15 +94,20 @@ url.rewrite-once = (
|
|||
module/controller/action. Finally, it will also match any additional
|
||||
parameters appended to the URI by default -
|
||||
controller/action/var1/value1/var2/value2.
|
||||
<note>
|
||||
<para>
|
||||
Module name must be defined like application.module="Index,Foo,Bar"
|
||||
in this case, only index, foo and bar can be considerd as a module name,
|
||||
defaultly, there is only one module name "Index" was preconfigured.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Module name must be defined in config, considering application.module="Index,Foo,Bar",
|
||||
in this case, only index, foo and bar can be considerd as a module name.
|
||||
if doesn't config, there is only one module named "Index".
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Some examples of how such routes are matched:
|
||||
<example>
|
||||
<title><classname>Yaf_Route_Static</classname>(default
|
||||
route)example</title>
|
||||
<programlisting role="conf">
|
||||
<![CDATA[
|
||||
// Assuming the following configure:
|
||||
|
@ -115,6 +147,7 @@ http://example/blog/archive/list/sort/alpha/date/desc
|
|||
date == desc
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
</para>
|
||||
</section>
|
||||
|
|
|
@ -31,13 +31,51 @@
|
|||
<para>
|
||||
A ini config file path, or a config array
|
||||
</para>
|
||||
<para>
|
||||
If is a ini config file, there should be a section named as the one
|
||||
defined by <link linkend="ini.yaf.environ">yaf.environ</link>, which
|
||||
is "product" by default.
|
||||
</para>
|
||||
<para>
|
||||
And the config entry(and there default value) list blow:
|
||||
<example>
|
||||
<title>A ini config file example</title>
|
||||
<programlisting role="ini" xml:id="yaf.application.ini">
|
||||
<![CDATA[
|
||||
[product]
|
||||
;this one should alway be defined, and have no default value
|
||||
application.directory=APPLICATION_PATH
|
||||
|
||||
;following configs have default value, you may no need to define them
|
||||
application.library = APPLICATION_PATH . "/library"
|
||||
application.dispatcher.throwException=1
|
||||
application.dispatcher.catchException=1
|
||||
|
||||
application.baseUri=""
|
||||
|
||||
;the php script ext name
|
||||
ap.ext=php
|
||||
|
||||
;the view template ext name
|
||||
ap.view.ext=phtml
|
||||
|
||||
ap.dispatcher.defaultModuel=Index
|
||||
ap.dispatcher.defaultController=Index
|
||||
ap.dispatcher.defaultAction=index
|
||||
|
||||
;defined modules
|
||||
ap.modules=Index
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>envrion</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
|
||||
Which section will be loaded as the final config
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
Loading…
Reference in a new issue