Hello! Trying to implement Phalcon Multimodule arc. Doing all just like it said in documentation, but I have the problem: my site don't want to show anything but IndexController/indexAction.
Any other route than '/' - class 'index' was not found on handler 'index'. What can be problem?
My Module:
<?php
namespace Multi\Frontend;
use Phalcon\Loader;
use Phalcon\Mvc\View\Simple as SimpleView;
use Phalcon\DiInterface;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\ModuleDefinitionInterface;
use Phalcon\Mvc\View\Engine\Volt;
class Module implements ModuleDefinitionInterface
{
public function registerAutoLoaders(DiInterface $di = null)
{
$loader = new Loader();
$loader->registerNamespaces(
array(
'Multi\Frontend\Controllers' => '../app/frontend/controllers/',
'Multi\Frontend\Models' => '../app/frontend/models/'
)
);
$loader->register();
}
public function registerServices(DiInterface $di)
{
$di->set('dispatcher', function() {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Multi\Frontend\Controllers');
return $dispatcher;
});
$di->set('view', function() {
$view = new SimpleView();
$view->setViewsDir('../app/frontend/views/');
$view->registerEngines(
array(
".volt" => function($view, $di) {
$volt = new Volt($view, $di);
$volt->setOptions(
array(
'compiledPath' => '../storage/volt',
'compileAlways' => true
)
);
return $volt;
}
)
);
return $view;
});
}
}
My index.php
<?php
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Application;
use Phalcon\Di\FactoryDefault;
use Phalcon\Session\Adapter\Files as Session;
$di = new FactoryDefault();
$di->set('router', function() {
$router = new Router();
$router->setDefaultModule("frontend");
$router->add('/login',
array(
'module' => 'frontend',
'controller' => 'Index',
'action' => 'login'
)
);
return $router;
});
$di->set('session', function () {
$session = new Session();
$session->start();
return $session;
}
);
try {
$application = new Application($di);
$application->registerModules(
array(
'frontend' => array(
'className' => 'Multi\Frontend\Module',
'path' => '../app/frontend/Module.php'
),
'backend' => array(
'className' => 'Multi\Backend\Module',
'path' => '../app/backend/Module.php'
)
)
);
$application->useImplicitView(false);
echo $application->handle()->getContent();
} catch(\Exception $e) {
echo $e->getMessage();
}
Thank you!