0

我无法在 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.
4

1 回答 1

0

我猜你不需要 double return。您的 include 中有一个,服务关闭中有一个。从 routes.php 中删除它并执行以下操作:

$di['router'] = function () {
    require __DIR__ . '/config/routes.php';
    return $router;
};

或将其留在那里并执行以下操作:

$di['router'] = function () {
    require __DIR__ . '/config/routes.php';
};

第一个选项感觉更自然,IMO。如果它是一个多模块应用程序,你还需要在你的路由中指定模块,看看这里

$router->add('/:controller/:action/:params', array(
    'module' => "frontend",
    'controller' => 1,
    'action' => 2,
    'params' => 3
))->setName('front-full');
于 2014-07-02T05:18:46.507 回答