Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- try {
- /**
- * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
- */
- $di = new \Phalcon\DI\FactoryDefault();
- /**
- * Registering a router
- */
- $di['router'] = function () {
- $router = new \Phalcon\Mvc\Router(false);
- $router->setDefaultModule("frontend");
- $router->add("/admin", array(
- 'module' => 'backend',
- 'controller' => 'index',
- 'action' => 'index',
- ),['GET'])->setName("admin");
- $router->add("/", array(
- 'module' => 'frontend',
- 'controller' => 'index',
- 'action' => 'index',
- ),['GET']);
- $router->notFound(
- [
- 'module' => 'frontend',
- 'controller' => 'index',
- "action" => "route404"
- ]
- );
- return $router;
- };
- /**
- * 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;
- });
- /**
- * Handle the request
- */
- $application = new \Phalcon\Mvc\Application();
- $application->setDI($di);
- /**
- * Register application modules
- */
- $application->registerModules(array(
- 'frontend' => array(
- 'className' => 'CloudStore\Frontend\Module',
- 'path' => '../apps/frontend/Module.php'
- ),
- 'backend' => array(
- 'className' => 'CloudStore\Backend\Module',
- 'path' => '../apps/backend/Module.php'
- )
- ));
- echo $application->handle()->getContent();
- } catch (Phalcon\Exception $e) {
- echo $e->getMessage();
- } catch (PDOException $e) {
- echo $e->getMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement