cakephp 3.0插件路由无法正常工作

时间:2015-08-15 13:03:45

标签: cakephp plugins url-routing cakephp-3.0

我在app_root_directory \ plugins \ Business \ config \ routes.php中有以下代码 当我将以下路线添加到此文件时,它不起作用

Router::plugin( 'Business', ['path' => '/' ], function ($routes) {
    $routes->connect(
            '/:state/localities', ['controller' => 'Cities', 'action' => 'localities', 'plugin' => 'Business' ], [
        'state' => '[0-9a-z-]+', 'pass' => ['state' ] ]
    );

    $routes->fallbacks( 'InflectedRoute' );
} );

我正在访问http://example.com/ab/localities 当路由被添加到app_root_directory \ config \ routes.php时,它的工作原理是什么?

Router::scope( '/', function ($routes) {
    $routes->connect(
            '/:state/localities', ['controller' => 'Cities', 'action' => 'localities', 'plugin' => 'Business' ], [
        'state' => '[0-9a-z-]+', 'pass' => ['state' ] ]
    );

    $routes->fallbacks( 'InflectedRoute' );
} );

0 个答案:

没有答案