diff --git a/reference/yaf/yaf_loader/registerlocalnamespace.xml b/reference/yaf/yaf_loader/registerlocalnamespace.xml index 8c07c4846ebc..b97dd2619759 100644 --- a/reference/yaf/yaf_loader/registerlocalnamespace.xml +++ b/reference/yaf/yaf_loader/registerlocalnamespace.xml @@ -10,13 +10,13 @@ &reftitle.description; - public voidYaf_Loader::registerLocalNamespace + public Yaf_LoaderfalseYaf_Loader::registerLocalNamespace mixedprefix - Register local class prefix name, Yaf_Loader search + Register local class prefix name, Yaf_Loader searches classes in two library directories, the one is configured via application.library.directory(in + linkend="configuration.yaf.library">application.library.directory (in application.ini) which is called local library directory; the other is configured via yaf.library (in php.ini) which is called global library directory, since it can be shared @@ -27,17 +27,18 @@ determine which library directory should be searched in by examining the prefix name of the missed classname. - If the prefix name is registered as a localnamespack then look for it in + If the prefix name is registered as a local namespace then look for it in local library directory, otherwise look for it in global library directory. - - If yaf.library is not configured, then the global library directory is - assumed to be the local library directory. in that case, all autoloading - will look for local library directory. - + + If yaf.library is not configured, then the global library directory is + assumed to be the local library directory. In that case, all autoloading + will look for local library directory. + + But if you want your Yaf application be strong, then always register your own classes as local classes. - + @@ -49,8 +50,8 @@ prefix - a string or an array of class name prefix. - all class prefix with these prefix will be loaded in local library path. + A &string; or an &array; of class name prefix. + All class prefix with these prefix will be loaded in local library path. @@ -60,7 +61,7 @@ &reftitle.returnvalues; - bool + Returns the Yaf_Loader instance on success,&return.falseforfailure;. @@ -71,7 +72,9 @@ registerLocalNamespace("Baidu"); $loader->registerLocalNamespace(array("Sina", "Weibo")); diff --git a/reference/yaf/yaf_loader/registernamespace.xml b/reference/yaf/yaf_loader/registernamespace.xml index 03457640eb85..4d4e5df362b1 100644 --- a/reference/yaf/yaf_loader/registernamespace.xml +++ b/reference/yaf/yaf_loader/registernamespace.xml @@ -10,20 +10,20 @@ &reftitle.description; - public boolYaf_Loader::registerNamespace - stringarraynamespaces + public Yaf_LoaderfalseYaf_Loader::registerNamespace + stringarraynamespace stringpath Register a namespace with searching path, Yaf_Loader - searchs classes under this namespace in path, the one is also could be - configureded via - application.library.directory.namespace(in application.ini); + searches classes under this namespace in path, the one is also could be + configured via + application.library.namespace (in application.ini). - Yaf still think underline as folder separator. + Yaf still think underscore as folder separator. @@ -36,7 +36,7 @@ namespace - a string of namespace, or an array of namespaces with paths. + A &string; of namespace, or an &array; of namespaces with paths. @@ -44,7 +44,7 @@ path - a string of path, it is better to use abosolute path here for performance + A &string; of path, it is better to use abosolute path here for performance. @@ -54,7 +54,7 @@ &reftitle.returnvalues; - bool + Returns the Yaf_Loader instance on success,&return.falseforfailure;. @@ -65,16 +65,18 @@ registerNamespace("\Vendor\PHP", "/var/lib/php"); $loader->registerNamespace(array( "\Vendor\ASP" => "/var/lib/asp", "\Vendor\JSP" => "/usr/lib/vendor/", )); -$loader->autoload("\Vendor\PHP\Dummy"); //load '/var/lib/php/Dummy.php' -$loader->autoload("\Vendor\PHP\Foo_Bar"); //load '/var/lib/php/Foo/Bar.php' -$loader->autoload("\Vendor\JSP\Dummy"); //load '/usr/lib/vendor/Dummy.php' +$loader->autoload("\Vendor\PHP\Dummy"); // Load '/var/lib/php/Dummy.php' +$loader->autoload("\Vendor\PHP\Foo_Bar"); // Load '/var/lib/php/Foo/Bar.php' +$loader->autoload("\Vendor\JSP\Dummy"); // Load '/usr/lib/vendor/Dummy.php' ?> ]]> diff --git a/reference/yaf/yaf_route_regex/construct.xml b/reference/yaf/yaf_route_regex/construct.xml index 5ae1ae00038e..d632e6071922 100644 --- a/reference/yaf/yaf_route_regex/construct.xml +++ b/reference/yaf/yaf_route_regex/construct.xml @@ -29,7 +29,7 @@ match - A complete Regex pattern, will be used to match a request uri, if + A complete Regex pattern, will be used to match a request URI, if doesn't matched, Yaf_Route_Regex will return &false;. @@ -39,12 +39,12 @@ route - When the match pattern matches the request uri, + When the match pattern matches the request URI, Yaf_Route_Regex will use this to decide which - m/c/a to routed. + m/c/a to be routed. - either of m/c/a in this array is optional, if you don't assign a + Either of m/c/a in this &array; is optional, if you don't assign a specific value, it will be routed to default. @@ -53,7 +53,7 @@ map - An array to assign name to the captures in the match result. + An &array; to assign name to the captures in the match result. @@ -69,11 +69,11 @@ reverse - a string, used to assemble url, see + A &string;, used to assemble URL, see Yaf_Route_Regex::assemble. - this parameter is introduced in 2.3.0 + This parameter is introduced in 2.3.0 @@ -96,22 +96,23 @@ getRouter()->addRoute("name", - new Yaf_Route_Regex( - "#^/product/([^/]+)/([^/])+#", //match request uri leading "/product" - array( - 'controller' => "product", //route to product controller, - ), - array( - 1 => "name", // now you can call $request->getParam("name") - 2 => "id", // to get the first captrue in the match pattern. - ) + +/** + * Add a regex route to Yaf_Router route stack + */ +Yaf_Dispatcher::getInstance()->getRouter()->addRoute( + "name", + new Yaf_Route_Regex( + "#^/product/([^/]+)/([^/])+#", // Match request URI leading "/product" + array( + 'controller' => "product", // Route to product controller + ), + array( + 1 => "name", // The first capture in the match pattern is now available via $request->getParam("name") + 2 => "id", ) - ); -?> + ) +); ]]> @@ -120,22 +121,23 @@ getRouter()->addRoute("name", - new Yaf_Route_Regex( - "#^/product/([^/]+)/([^/])+#i", //match request uri leading "/product" - array( - 'controller' => ":name", // route to :name, which is $1 in the match result as controller name - ), - array( - 1 => "name", // now you can call $request->getParam("name") - 2 => "id", // to get the first captrue in the match pattern. - ) + +/** + * Use match result as MVC name + */ +Yaf_Dispatcher::getInstance()->getRouter()->addRoute( + "name", + new Yaf_Route_Regex( + "#^/product/([^/]+)/([^/])+#i", // Match request URI leading "/product" + array( + 'controller' => ":name", // Route to :name which is $1 in the match result as controller name + ), + array( + 1 => "name", // The first capture in the match pattern is now available via $request->getParam("name") + 2 => "id", ) - ); -?> + ) +); ]]> @@ -144,22 +146,22 @@ getRouter()->addRoute("name", - new Yaf_Route_Regex( - "#^/product/(?[^/]+)/([^/])+#i", //match request uri leading "/product" - array( - 'controller' => ":name", // route to :name, - // which is named capture group 'name' in the match result as controller name - ), - array( - 2 => "id", // to get the first captrue in the match pattern. - ) + +/** + * Use match result as MVC name + */ +Yaf_Dispatcher::getInstance()->getRouter()->addRoute( + "name", + new Yaf_Route_Regex( + "#^/product/(?[^/]+)/([^/])+#i", // Match request URI leading "/product" + array( + 'controller' => ":name", // Route to :name which is named capture group 'name' in the match result as controller name + ), + array( + 2 => "id", ) - ); -?> + ) +); ]]> @@ -168,25 +170,27 @@ array( - "type" => "regex", //Yaf_Route_Regex route - "match" => "#(.*)#", //match arbitrary request uri - "route" => array( - 'controller' => "product", //route to product controller, - 'action' => "dummy", //route to dummy action - ), - "map" => array( - 1 => "uri", // now you can call $request->getParam("uri") - ), + +/** + * Add a regex route to Yaf_Router route stack by calling addConfig + */ +$config = array( + "name" => array( + "type" => "regex", // Yaf_Route_Regex route + "match" => "#(.*)#", // Match arbitrary request URI + "route" => array( + 'controller' => "product", // Route to product controller + 'action' => "dummy", // Route to dummy action ), - ); - Yaf_Dispatcher::getInstance()->getRouter()->addConfig( - new Yaf_Config_Simple($config)); -?> + "map" => array( + 1 => "uri", // The URI is now available via $request->getParam("uri") + ), + ), +); + +Yaf_Dispatcher::getInstance()->getRouter()->addConfig( + new Yaf_Config_Simple($config) +); ]]>