我无法在phalcon中注册自定义路线。我不知道是什么问题。
$di['router'] = function () {
return require __DIR__ . '/config/routes.php';
};
路径文件中的我有
$router = new Phalcon\Mvc\Router();
//$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);
$router->add('/confirm/{code}/{email}', array(
'controller' => 'user_control',
'action' => 'confirmEmail'
));
/*$router->add('/reset-password/{code}/{email}', array(
'controller' => 'user_control',
'action' => 'resetPassword'
));*/
return $router;
当我去/confirm/32sadfasdfwef/www@gmail.com
时我正在
Ilm\Frontend\Controllers\ConfirmController handler class cannot be loaded
它的多模块应用程序。
And if i do die() in $di['router'] it does not do anything.
答案 0 :(得分:0)
我猜你不需要双return
。您的include中有一个,服务中有一个。从routes.php中删除它并执行以下操作:
$di['router'] = function () {
require __DIR__ . '/config/routes.php';
return $router;
};
或者留在那里并执行此操作:
$di['router'] = function () {
require __DIR__ . '/config/routes.php';
};
第一种选择感觉更自然,IMO。如果它是一个多模块应用,您还需要在路线中指定模块,看看here。
$router->add('/:controller/:action/:params', array(
'module' => "frontend",
'controller' => 1,
'action' => 2,
'params' => 3
))->setName('front-full');