Hi, i have and other problem with multi module project, i cant access from the base url: https://https://feedback/ i defined this route:
$router->setDefaults(array(
'module' => 'backend',
'controller' => 'login',
'action' => 'index'
));
but if i access from: https://feedback/backend/login this work!.. any Help please?
this is my bootstrap.
<?php
error_reporting(E_ALL);
try {
define('SITE_DOMAIN', $_SERVER['HTTP_HOST']);
/**
* Read the configuration
*/
$config = include(__DIR__ . '/../app/config/' . SITE_DOMAIN . '_db.php');
/**
* The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
*/
$di = new \Phalcon\DI\FactoryDefault();
/**
* The URL component is used to generate all kind of urls in the application
*/
$di->set('url', function() use ($config) {
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->set('db', function() use ($config) {
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => $config->database->host,
"username" => $config->database->username,
"password" => $config->database->password,
"dbname" => $config->database->name
));
});
/**
* If the configuration specify the use of metadata adapter use it or use memory otherwise
*/
$di->set('modelsMetadata', function() use ($config) {
if (isset($config->models->metadata)) {
$metadataAdapter = 'Phalcon\Mvc\Model\Metadata\\' . $config->models->metadata->adapter;
return new $metadataAdapter();
} else {
return new \Phalcon\Mvc\Model\Metadata\Memory();
}
});
/**
* Start the session the first time some component request the session service
*/
$di->set('session', function() {
$session = new \Phalcon\Session\Adapter\Files();
$session->start();
return $session;
});
//Specify routes for modules
$di->set('router', function () {
$router = new \Phalcon\Mvc\Router(false);
$router->setDefaultModule("backend");
$router->setDefaultAction('index');
$router->setDefaults(array(
'module' => 'backend',
'controller' => 'login',
'action' => 'index'
));
$router->notFound(array(
'module' => 'backend',
'controller' => 'error',
'action' => 'index'
));
$router->add('/:module/:controller', array(
'module' => 1,
'controller' => 2,
'action' => 'index',
));
$router->add('/:module/:controller/:action/:params', array(
'module' => 1,
'controller' => 2,
'action' => 3,
'params' => 4
));
return $router;
});
/**
* Handle the request
*/
$application = new \Phalcon\Mvc\Application();
$application->setDI($di);
// Register the installed modules
$application->registerModules(
array(
'public' => array(
'className' => 'Frontend\Module',
'path' => '../app/frontend/Module.php',
),
'backend' => array(
'className' => 'Backend\Module',
'path' => '../app/backend/Module.php',
)
)
);
echo $application->handle()->getContent();
} catch (Phalcon\Exception $e) {
echo $e->getMessage();
} catch (PDOException $e) {
echo $e->getMessage();
}