I use phalcon 1.3.4 with PHP 5.4
Here's my full code:
<?php
//These routes simulate real URIs
$testRoutes = array(
'/',
'/fooBar'
);
/** @var \Phalcon\Mvc\Router $router */
$router = new Phalcon\Mvc\Router(FALSE);
$router->removeExtraSlashes(TRUE);
$router->setDefaults(array(
'namespace' => 'Streepoly\Controller',
'controller' => 'index',
'action' => 'index'
));
$router->notFound(array(
'controller' => 'index',
'action' => 'show404'
));
$router->addGet('/', array(
'controller' => 'index',
'action' => 'index'
));
//Testing each route
foreach ($testRoutes as $testRoute) {
$router->handle($testRoute);
echo 'Testing ', $testRoute . PHP_EOL;
//Check if some route was matched
if ($router->wasMatched()) {
echo 'Controller: ', $router->getControllerName() . PHP_EOL;
echo 'Action: ', $router->getActionName() . PHP_EOL;
} else {
echo 'The route wasn\'t matched by any route' . PHP_EOL;
}
echo PHP_EOL;
}
?>
The full error message I get is the following:
( ! ) Fatal error: Uncaught exception 'Phalcon\Mvc\Router\Exception' with message 'Unexpected value type: expected object implementing Phalcon\DiInterface, null given' in /home/dompie/project/public/testroutes.php on line 32
( ! ) Phalcon\Mvc\Router\Exception: Unexpected value type: expected object implementing Phalcon\DiInterface, null given in /home/dompie/project/public/testroutes.php on line 32
Call Stack
# Time Memory Function Location
1 0.0005 246712 {main}( ) ../testroutes.php:0
2 0.0006 251320 handle ( string(1) ) ../testroutes.php:32
Any suggestions what's wrong?