Example #1
0
<?php

use Phalcon\Loader;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Router;
define('APP_PATH', realpath('..') . '/');
try {
    // Register an autoloader
    $loader = new Loader();
    $loader->registerDirs(array(APP_PATH . 'app/controllers/', APP_PATH . 'app/models/', APP_PATH . 'app/conf/', APP_PATH . 'app/lib/', APP_PATH . 'app/service/page'))->register();
    // Create a DI
    $di = new FactoryDefault();
    // Register Services
    ServiceConfig::register($di);
    // Handle the request
    $application = new Application($di);
    echo $application->handle()->getContent();
} catch (Exception $e) {
    echo "PhalconException: ", $e->getMessage();
}
 /**
  * Callback for class autoloading in linux flavours.
  * 
  * @param string $classPath Path of the class to load
  * 
  * @return void
  */
 public function autoLoadNonWindows($classPath)
 {
     $dirName = "library";
     if ($classPath == ServiceConfig::GetServiceInfo("classname")) {
         $dirName = "services";
         $classPath = ServiceConfig::GetServiceInfo("path") . "/" . $classPath;
     }
     $classPath = str_replace("\\", "/", $classPath);
     include_once self::$basePath . "/" . $dirName . "/" . $classPath . self::FILEEXTENSION;
 }