GithubHelp home page GithubHelp logo

\Yaf\Route\Regex路由不到 about yaf HOT 3 CLOSED

laruence avatar laruence commented on July 2, 2024
\Yaf\Route\Regex路由不到

from yaf.

Comments (3)

laruence avatar laruence commented on July 2, 2024

Regex要写完全的正则表达式 '#girl/([\d]+)#'

from yaf.

dev2geek avatar dev2geek commented on July 2, 2024

Bingo,明白了,感谢~

from yaf.

redybai avatar redybai commented on July 2, 2024

设置路由:
public function _initRoute(Yaf_Dispatcher $dispatcher) {
$router = Yaf_Dispatcher::getInstance()->getRouter();
$route = new Yaf_Route_Regex (
'testRoute/([a-zA-Z_0-9]+)',
array (
"controller" => "testRoute",
"action" => "index"
),
array()
) ;
$router->addRoute('testRoute', $route);
var_dump($router);
}

访问链接:http://myyaf.com/testRoute/index
浏览器上输出 路由信息:
object(Yaf_Router)#5 (2) {
["_routes":protected]=>
array(2) {
["_default"]=>
object(Yaf_Route_Static)#6 (0) {
}
["testRoute"]=>
object(Yaf_Route_Regex)#10 (4) {
["_route":protected]=>
string(25) "testRoute/([a-zA-Z_0-9]+)"
["_default":protected]=>
array(2) {
["controller"]=>
string(9) "testRoute"
["action"]=>
string(5) "index"
}
["_maps":protected]=>
array(0) {
}
["_verify":protected]=>
NULL
}
}
["_current":protected]=>
NULL
}

_current为NULL
也的确是没转向指定的controler。
对应的testRoute控制器是这么写的:

from yaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.