Guest User

index.php

a guest
Feb 28th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. use Phalcon\Loader;
  5. use Phalcon\Mvc\View;
  6. use Phalcon\Mvc\Application;
  7. use Phalcon\Di\FactoryDefault;
  8. use Phalcon\Mvc\Url as UrlProvider;
  9. use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
  10.  
  11.   try {
  12.      //Registra o autoloader
  13.      $loader = new Loader();
  14.      $loader->registerDirs(array(
  15.         "../app/controllers/",
  16.         "../app/models/"
  17.      ))->register();
  18.  
  19.     //Cria o DI
  20.     $di = new FactoryDefault();
  21.  
  22.  
  23.     //Setup the view component
  24.     $di->set("view", function(){
  25.        $view = new View();
  26.        $view->setViewsDir("../app/views/");
  27.        return $view;
  28.     });
  29.  
  30.     //Setup a base URI so thal tall generated URIs include the projetoPhalcon folder
  31.     $di->set("url", function() {
  32.        $url = new UrlProvider();
  33.        $url->setBaseUri("/projetoPhalcon/");
  34.        return $url;
  35.     });
  36.  
  37.    //Handle the request
  38.    $application = new Application($di);
  39.  
  40.    echo $application->handle()->getContent();
  41.  
  42.  
  43.   } catch(\Exception $e) {
  44.     echo "PhalconException: ", $e->getMessage();
  45.   }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment