我在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' );
} );