From 2e6009685efff98c0c7045e69eda6fec3786d0ad Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Mon, 13 Apr 2026 18:30:55 +0300 Subject: [PATCH 01/12] registerlocalnamespace.xml Fix typo --- reference/yaf/yaf_loader/registerlocalnamespace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/yaf/yaf_loader/registerlocalnamespace.xml b/reference/yaf/yaf_loader/registerlocalnamespace.xml index 8c07c4846ebc..22f8614238ef 100644 --- a/reference/yaf/yaf_loader/registerlocalnamespace.xml +++ b/reference/yaf/yaf_loader/registerlocalnamespace.xml @@ -27,7 +27,7 @@ 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. From b88761be9881a32dd717b93bd971466e4213807c Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Mon, 13 Apr 2026 20:50:49 +0300 Subject: [PATCH 02/12] registerlocalnamespace.xml Amend return type --- .../yaf/yaf_loader/registerlocalnamespace.xml | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/reference/yaf/yaf_loader/registerlocalnamespace.xml b/reference/yaf/yaf_loader/registerlocalnamespace.xml index 22f8614238ef..5833b2215913 100644 --- a/reference/yaf/yaf_loader/registerlocalnamespace.xml +++ b/reference/yaf/yaf_loader/registerlocalnamespace.xml @@ -10,7 +10,7 @@ &reftitle.description; - public voidYaf_Loader::registerLocalNamespace + public Yaf_LoaderfalseYaf_Loader::registerLocalNamespace mixedprefix @@ -30,14 +30,15 @@ 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, or &false; on failure. @@ -71,7 +72,9 @@ registerLocalNamespace("Baidu"); $loader->registerLocalNamespace(array("Sina", "Weibo")); From c566582f2a482ecc795fbabd95a42a9a02106943 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 02:44:15 +0300 Subject: [PATCH 03/12] registerlocalnamespace.xml Fix typo From 14e57a50d22dc4f833021dc1dadbd2b9284eaae3 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 02:45:50 +0300 Subject: [PATCH 04/12] registerlocalnamespace.xml Fix typo --- reference/yaf/yaf_loader/registerlocalnamespace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/yaf/yaf_loader/registerlocalnamespace.xml b/reference/yaf/yaf_loader/registerlocalnamespace.xml index 5833b2215913..218ee585d7c3 100644 --- a/reference/yaf/yaf_loader/registerlocalnamespace.xml +++ b/reference/yaf/yaf_loader/registerlocalnamespace.xml @@ -14,7 +14,7 @@ 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 application.ini) which is called local library directory; the other is From ab2f6538f6571dbafb2627ff3f7955b4928c079a Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:04:58 +0300 Subject: [PATCH 05/12] registerlocalnamespace.xml To variable --- reference/yaf/yaf_loader/registerlocalnamespace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/yaf/yaf_loader/registerlocalnamespace.xml b/reference/yaf/yaf_loader/registerlocalnamespace.xml index 218ee585d7c3..f7044d880084 100644 --- a/reference/yaf/yaf_loader/registerlocalnamespace.xml +++ b/reference/yaf/yaf_loader/registerlocalnamespace.xml @@ -61,7 +61,7 @@ &reftitle.returnvalues; - Returns the Yaf_Loader instance on success, or &false; on failure. + Returns the Yaf_Loader instance on success,&return.falseforfailure;. From 9bf4b84a5e65c231e46ea538195992b9eba66033 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:05:59 +0300 Subject: [PATCH 06/12] registerlocalnamespace.xml Add space --- reference/yaf/yaf_loader/registerlocalnamespace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/yaf/yaf_loader/registerlocalnamespace.xml b/reference/yaf/yaf_loader/registerlocalnamespace.xml index f7044d880084..b97dd2619759 100644 --- a/reference/yaf/yaf_loader/registerlocalnamespace.xml +++ b/reference/yaf/yaf_loader/registerlocalnamespace.xml @@ -16,7 +16,7 @@ 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 From d82107804bf617021577368ed68d4d1970132bd5 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:07:20 +0300 Subject: [PATCH 07/12] registernamespace.xml Fix typo and amend return type And the same: ```php registerNamespace("App\Fake", "path"); var_dump($result); // object(Yaf_Loader) $result = @$loader->registerNamespace(null, null); var_dump($result); // bool(false) ``` --- .../yaf/yaf_loader/registernamespace.xml | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/reference/yaf/yaf_loader/registernamespace.xml b/reference/yaf/yaf_loader/registernamespace.xml index 03457640eb85..09857eab86fd 100644 --- a/reference/yaf/yaf_loader/registernamespace.xml +++ b/reference/yaf/yaf_loader/registernamespace.xml @@ -10,15 +10,15 @@ &reftitle.description; - public boolYaf_Loader::registerNamespace + public Yaf_LoaderfalseYaf_Loader::registerNamespace stringarraynamespaces stringpath Register a namespace with searching path, Yaf_Loader - searchs classes under this namespace in path, the one is also could be + searches classes under this namespace in path, the one is also could be configureded via - application.library.directory.namespace(in application.ini); + application.library.directory.namespace (in application.ini); @@ -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' ?> ]]> From 7a5fce730803dd6236f38b187565e28dbd9aae10 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:24:30 +0300 Subject: [PATCH 08/12] registernamespace.xml Amend the directive name --- reference/yaf/yaf_loader/registernamespace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/yaf/yaf_loader/registernamespace.xml b/reference/yaf/yaf_loader/registernamespace.xml index 09857eab86fd..7756fc4211b9 100644 --- a/reference/yaf/yaf_loader/registernamespace.xml +++ b/reference/yaf/yaf_loader/registernamespace.xml @@ -18,7 +18,7 @@ Register a namespace with searching path, Yaf_Loader searches classes under this namespace in path, the one is also could be configureded via - application.library.directory.namespace (in application.ini); + application.library.namespace (in application.ini); From 191fba808fc12a10be4945a0e2a0af81c24caec6 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:28:08 +0300 Subject: [PATCH 09/12] registernamespace.xml `;` to `.` --- reference/yaf/yaf_loader/registernamespace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/yaf/yaf_loader/registernamespace.xml b/reference/yaf/yaf_loader/registernamespace.xml index 7756fc4211b9..ebb5e9615a50 100644 --- a/reference/yaf/yaf_loader/registernamespace.xml +++ b/reference/yaf/yaf_loader/registernamespace.xml @@ -18,7 +18,7 @@ Register a namespace with searching path, Yaf_Loader searches classes under this namespace in path, the one is also could be configureded via - application.library.namespace (in application.ini); + application.library.namespace (in application.ini). From d627fa9de71fb3aa23dd3a3a6e2d7a3e24095ff3 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:41:58 +0300 Subject: [PATCH 10/12] =?UTF-8?q?registernamespace.xml=20Fix=20typo.=20`un?= =?UTF-8?q?derline`=20=E2=86=92=C2=A0`underscore`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reference/yaf/yaf_loader/registernamespace.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/yaf/yaf_loader/registernamespace.xml b/reference/yaf/yaf_loader/registernamespace.xml index ebb5e9615a50..743970e3f88e 100644 --- a/reference/yaf/yaf_loader/registernamespace.xml +++ b/reference/yaf/yaf_loader/registernamespace.xml @@ -17,13 +17,13 @@ Register a namespace with searching path, Yaf_Loader searches classes under this namespace in path, the one is also could be - configureded via + configured via application.library.namespace (in application.ini). - Yaf still think underline as folder separator. + Yaf still think underscore as folder separator. From 24c97514a2e49c79add24b34f43ee918574e4757 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 03:49:17 +0300 Subject: [PATCH 11/12] registernamespace.xml Fix parameter name --- reference/yaf/yaf_loader/registernamespace.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/yaf/yaf_loader/registernamespace.xml b/reference/yaf/yaf_loader/registernamespace.xml index 743970e3f88e..4d4e5df362b1 100644 --- a/reference/yaf/yaf_loader/registernamespace.xml +++ b/reference/yaf/yaf_loader/registernamespace.xml @@ -11,12 +11,12 @@ &reftitle.description; public Yaf_LoaderfalseYaf_Loader::registerNamespace - stringarraynamespaces + stringarraynamespace stringpath Register a namespace with searching path, Yaf_Loader - searches classes under this namespace in path, the one is also could be + searches classes under this namespace in path, the one is also could be configured via application.library.namespace (in application.ini). From 55074ce783411f99bb6ebe482d4709edeb8d5c08 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Tue, 14 Apr 2026 06:57:40 +0300 Subject: [PATCH 12/12] construct.xml Fix typo, amend examples --- reference/yaf/yaf_route_regex/construct.xml | 144 ++++++++++---------- 1 file changed, 74 insertions(+), 70 deletions(-) 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) +); ]]>