Advertisement
Guest User

Untitled

a guest
May 2nd, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4.  
  5. try {
  6.  
  7.     /**
  8.      * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
  9.      */
  10.     $di = new \Phalcon\DI\FactoryDefault();
  11.  
  12.     /**
  13.      * Registering a router
  14.      */
  15.     $di['router'] = function () {
  16.  
  17.         $router = new \Phalcon\Mvc\Router(false);
  18.  
  19.         $router->setDefaultModule("frontend");
  20.  
  21.         $router->add("/admin", array(
  22.             'module'     => 'backend',
  23.             'controller' => 'index',
  24.             'action'     => 'index',
  25.         ),['GET'])->setName("admin");
  26.  
  27.         $router->add("/", array(
  28.             'module'     => 'frontend',
  29.             'controller' => 'index',
  30.             'action'     => 'index',
  31.         ),['GET']);
  32.  
  33.         $router->notFound(
  34.             [
  35.                 'module' => 'frontend',
  36.                 'controller' => 'index',
  37.                 "action" => "route404"
  38.             ]
  39.         );
  40.  
  41.         return $router;
  42.     };
  43.  
  44.     /**
  45.      * Start the session the first time some component request the session service
  46.      */
  47.     $di->set('session', function () {
  48.         $session = new \Phalcon\Session\Adapter\Files();
  49.         $session->start();
  50.  
  51.         return $session;
  52.     });
  53.  
  54.     /**
  55.      * Handle the request
  56.      */
  57.     $application = new \Phalcon\Mvc\Application();
  58.  
  59.     $application->setDI($di);
  60.  
  61.     /**
  62.      * Register application modules
  63.      */
  64.     $application->registerModules(array(
  65.         'frontend' => array(
  66.             'className' => 'CloudStore\Frontend\Module',
  67.             'path' => '../apps/frontend/Module.php'
  68.         ),
  69.         'backend' => array(
  70.             'className' => 'CloudStore\Backend\Module',
  71.             'path' => '../apps/backend/Module.php'
  72.         )
  73.     ));
  74.  
  75.     echo $application->handle()->getContent();
  76.  
  77. } catch (Phalcon\Exception $e) {
  78.     echo $e->getMessage();
  79. } catch (PDOException $e) {
  80.     echo $e->getMessage();
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement