2

I try to use a router with phalcon. This is how it is included in index.php right after registering the 'events manager':

$di->set('router', function(){
    require __DIR__.'/../app/config/routes.php';
    return $router;
});

and this is how the routes.php looks like:

<?php
$router = new Phalcon\Mvc\Router(false);

$router->add("/", array(
    'controller' => 'index',
    'action' => 'index'
));

$router->add("/topics", array(
    'controller' => 'wurst',
    'action' => 'index'
));

$router->handle();
return $router;

The website reacts as if the router was not existent. /topics and topics say this:

TopicsController handler class cannot be loaded

and I also cannot use a die("test"); function inside routes.php . nothing happens.
I also tried to activate it without a separate file, but the result was the same :(

(The sample web-application INVO was used as starting point for my site )

4

3 回答 3

4

$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); 将使用默认 $_SERVER['REQUEST_URI']

于 2014-06-24T06:21:30.927 回答
0

如果您在访问 domain.com/index.php 时您的索引/索引操作正在工作,请检查您是否使用了正确的 uri 源,如果使用 nginx 或 php 内置服务器,您可能会遇到路由问题和 $_GET['_uri '] 哪个 phalcon 用于处理 uris。

可以在有关 uri 源的 phalcon 路由器文档中找到更多相关信息 -> http://docs.phalconphp.com/en/latest/reference/routing.html#uri-sources

于 2014-04-10T20:48:07.230 回答
0

现在它似乎工作了:

Action 'route404' was not found on handler 'index'

问题是,我将在 index.php 中设置路由器的函数放在“设置调度程序函数”中。..没有看到右括号。

于 2014-04-10T22:47:08.307 回答