Hi all,
I have some troubles with urls when I try some tests with it, for example IndexController => indexAction:
-
There is a infinity loop when I type : domain.localhost/index/index/index/index/index/.... it's working
- With this url, it works to : domain.localhost/qsdqsd.qsdqsd_qsdqsd.qsdqsd ndsazl
$di->set('url', function() use ($baseUrl) {
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri($baseUrl);
return $url;
});
$di->set('dispatcher', function() use ($di) {
$dispatcher = new \Phalcon\Mvc\Dispatcher();
$dispatcher->setDefaultNamespace('App\Controllers');
$evManager = $di->getShared('eventsManager');
$evManager->attach("dispatch:beforeException", function($event, $dispatcher, $exception) use ($di) {
//if (ENVIRONMENT != 'development') {
switch ($exception->getCode()) {
case \Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(
array(
'controller' => 'errors',
'action' => 'show404',
)
);
return FALSE;
break;
default:
$dispatcher->forward(
array(
'controller' => 'errors',
'action' => 'uncaughtException',
)
);
return FALSE;
break; // for checkstyle
}
//}
});
$dispatcher->setEventsManager($evManager);
return $dispatcher;
}, true);
$di->set('router', function() {
// Init router
$router = new \Phalcon\Mvc\Router();
// Use $_SERVER['REQUEST_URI'] (NGINX)
if (!isset($_GET['_url']))
{
$router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
}
$router->removeExtraSlashes(true);
// Fetch routes from user
include (APP_DIR . '/config/routes.php');
// Inject
return $router;
});
Thx for your help