/**
  * If the class isn't already loaded, and an autoloader hasn't been set up
  * for the class (i.e. class not loaded), we will set up our own autoloader
  * for all namespaces and dirs registered and attempt to load the class
  *
  * @param $className
  * @throws Exception
  */
 protected function autoloadClass($className)
 {
     // has the class be loaded?
     if (class_exists($className)) {
         return;
     }
     if (!$this->ourLoader) {
         $this->ourLoader = new Loader();
         $ourLoaderNamespaces = array();
         $ourLoaderDirs = array();
         foreach ($this->namespaces as $ns) {
             if ($ns['ns']) {
                 $ourLoaderNamespaces[$ns['ns']] = $ns['dir'];
             } else {
                 $ourLoaderDirs[] = $ns['dir'];
             }
         }
         $this->ourLoader->registerNamespaces($ourLoaderNamespaces);
         $this->ourLoader->registerDirs($ourLoaderDirs);
     }
     $loaded = $this->ourLoader->autoLoad($className);
     if (!$loaded) {
         throw new \Exception('Unable to load autoload class ' . $className);
     }
 }
Ejemplo n.º 2
0
 /**
  * Init loader.
  *
  * @param DI            $di            Dependency Injection.
  * @param Config        $config        Config object.
  * @param EventsManager $eventsManager Event manager.
  *
  * @return Loader
  */
 protected function _initLoader($di, $config, $eventsManager)
 {
     /**
      * Add all required namespaces and modules from registry.
      * @var [type]
      */
     $registry = $di->get('registry');
     $namespaces = [];
     $bootstraps = [];
     foreach ($registry->modules as $module) {
         $moduleName = ucfirst($module);
         $namespaces[$moduleName] = $registry->directories->modules . $moduleName;
         $bootstraps[$module] = $moduleName . '\\Bootstrap';
     }
     $namespaces['Engine'] = $registry->directories->engine;
     $loader = new PhLoader();
     $loader->registerNamespaces($namespaces);
     // Register some directories
     $loader->registerDirs([ROOT_PATH . '/app/libraries']);
     $loader->setEventsManager($eventsManager);
     $loader->register();
     $this->registerModules($bootstraps);
     $di->set('loader', $loader);
     return $loader;
 }
Ejemplo n.º 3
0
 /**
  * Register a specific autoloader for the module
  * @param \Phalcon\DiInterface $di
  */
 public function registerAutoloaders(DiInterface $di = null)
 {
     $config = $this->_config;
     $loader = new Loader();
     $loader->registerNamespaces(array('Imports\\Controllers' => __DIR__ . '/Controllers', 'Imports\\Models' => __DIR__ . '/Models'));
     $loader->registerDirs(array(APP_PATH . $config->application->controllersDir, APP_PATH . $config->application->modelsDir, APP_PATH . $config->application->viewsDir, APP_PATH . $config->application->migrationsDir, APP_PATH . $config->application->pluginsDir, APP_PATH . $config->application->libraryDir, APP_PATH . $config->application->formsDir));
     $loader->register();
 }
Ejemplo n.º 4
0
 public function registerAutoloaders(DiInterface $dependencyInjector = null)
 {
     global $config;
     $loader = new Loader();
     $loader->registerNamespaces(array('Multiple\\Backend\\Controllers' => $config->backend->controllersDir, 'Multiple\\Backend\\Models' => $config->backend->modelsDir));
     $loader->registerDirs(array($config->backend->controllersDir, $config->backend->modelsDir));
     $loader->register();
 }
Ejemplo n.º 5
0
 /**
  * Register a specific autoloader for the module
  * @param \Phalcon\DiInterface $di
  */
 public function registerAutoloaders(DiInterface $di = null)
 {
     $config = $this->_config;
     $loader = new Loader();
     $loader->registerNamespaces(array(__NAMESPACE__ . '\\Controllers' => __DIR__ . '/controllers', __NAMESPACE__ . '\\Models' => __DIR__ . '/models', __NAMESPACE__ . '\\Forms' => __DIR__ . '/forms'));
     $loader->registerDirs(array($config->application->controllersDir, $config->application->modelsDir, $config->application->migrationsDir, $config->application->formsDir));
     $loader->register();
 }
Ejemplo n.º 6
0
 /**
  * Initializes the loader
  */
 protected function initLoader()
 {
     $config = $this->di['config'];
     // Creates the autoloader
     $loader = new PhLoader();
     $loader->registerDirs(array($config->application->controllersDir, $config->application->modelsDir));
     $loader->register();
     // Dump it in the DI to reuse it
     $this->di['loader'] = $loader;
 }
Ejemplo n.º 7
0
 /**
  * Registers an autoloader related to the module
  *
  * @param DiInterface $dependencyInjector
  */
 public function registerAutoloaders(DiInterface $dependencyInjector = null)
 {
     $loader = new Loader();
     //注册命名空间
     $loader->registerNamespaces(array('Api\\Controllers' => __DIR__ . '/controllers/', 'Api\\Models' => __DIR__ . '/models/'));
     //注册基本模型类名
     $loader->registerClasses(['ModelBase' => APP_PATH . '/base/ModelBase.php']);
     //惰性加载文件,模型、第三类库
     $loader->registerDirs(array(APP_PATH . '/library/', __DIR__ . '/models/'));
     $loader->register();
 }
Ejemplo n.º 8
0
 protected function initLoader()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Actions' => APP_PATH . '/actions/', 'Base' => APP_PATH . '/base/', 'Controllers' => APP_PATH . '/controllers/', 'Db' => APP_PATH . '/models/', 'Lib' => APP_PATH . '/library/']);
     $loader->registerClasses(['__' => VENDOR_PATH . '/Underscore.php']);
     $loader->registerDirs([ROOT_PATH]);
     $loader->register();
     // autoload vendor dependencies
     require_once VENDOR_PATH . '/autoload.php';
     $this->di['loader'] = $loader;
 }
Ejemplo n.º 9
0
 /**
  * HMVCApplication Constructor
  *
  * @param Phalcon\DiInterface
  */
 public function __construct(DiInterface $di)
 {
     $loader = new Loader();
     //Application Loader
     $loader->registerDirs(array('../app/controllers/'))->register();
     //Register the view service
     $di['view'] = function () {
         $view = new View();
         $view->setViewsDir('../app/views/');
         return $view;
     };
     //Register the app itself as a service
     $di['app'] = $this;
     //Sets the parent Id
     parent::setDI($di);
 }
Ejemplo n.º 10
0
 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 protected function registerServices()
 {
     $di = new FactoryDefault();
     require '../../../autoloader.php';
     $loader = new Loader();
     /**
      * We're a registering a set of directories taken from the configuration file
      */
     $loader->registerDirs(array(__DIR__ . '/../apps/library/'))->register();
     $router = new Router();
     $router->setDefaultModule("frontend");
     //Registering a router
     $di->set('router', function () use($router) {
         return $router;
     });
     $this->setDI($di);
 }
Ejemplo n.º 11
0
 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 protected function registerServices()
 {
     $di = new FactoryDefault();
     $loader = new Loader();
     /**
      * We're a registering a set of directories taken from the configuration file
      */
     $loader->registerDirs(array(__DIR__ . '/../apps/library/'))->register();
     //Registering a router
     $di->set('router', function () {
         $router = new Router();
         $router->setDefaultModule("frontend");
         $router->add('/:controller/:action', array('module' => 'frontend', 'controller' => 1, 'action' => 2));
         $router->add("/login", array('module' => 'backend', 'controller' => 'login', 'action' => 'index'));
         $router->add("/admin/products/:action", array('module' => 'backend', 'controller' => 'products', 'action' => 1));
         $router->add("/products/:action", array('module' => 'frontend', 'controller' => 'products', 'action' => 1));
         return $router;
     });
     $this->setDI($di);
 }
Ejemplo n.º 12
0
/**
 * Created by IntelliJ IDEA.
 * User: godsoul
 * Date: 2016/1/10
 * Time: 22:54
 */
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Micro;
use Phalcon\Loader;
use Phalcon\Db\Adapter\Pdo\Mysql as MysqlAdapter;
use Phalcon\Config\Adapter\Ini as ConfigIni;
use Phalcon\Mvc\Micro\Collection as MicroCollection;
// Setup loader
$loader = new Loader();
$loader->registerDirs(array(__DIR__ . '/app/models/', __DIR__ . '/app/controllers/', __DIR__ . '/library/'))->register();
// Read the configuration
$config = new ConfigIni(__DIR__ . '/config/config.ini');
//Start DI
$di = new FactoryDefault();
$di->set('redis', function () {
    return new RedisTest();
}, true);
// Start Micro
$app = new Micro();
$app->setDI($di);
// Setup the database service
$app['db'] = function () use($config) {
    return new MysqlAdapter(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname, "charset" => $config->database->charset));
};
// Include controllers
Ejemplo n.º 13
0
use Phalcon\Script;
use Phalcon\Version;
use Phalcon\Script\Color;
use Phalcon\Commands\CommandsListener;
use Phalcon\Loader;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Exception as PhalconException;
try {
    $extensionLoaded = true;
    if (!extension_loaded('phalcon')) {
        $extensionLoaded = false;
        include dirname(__FILE__) . '/scripts/Phalcon/Script.php';
        throw new Exception(sprintf("Phalcon extension isn't installed, follow these instructions to install it: %s", Script::DOC_INSTALL_URL));
    }
    $loader = new Loader();
    $loader->registerDirs(array(__DIR__ . '/scripts/'))->registerNamespaces(array('Phalcon' => __DIR__ . '/scripts/'))->register();
    if (Version::getId() < Script::COMPATIBLE_VERSION) {
        throw new Exception(sprintf("Your Phalcon version isn't compatible with Developer Tools, download the latest at: %s", Script::DOC_DOWNLOAD_URL));
    }
    if (!defined('TEMPLATE_PATH')) {
        define('TEMPLATE_PATH', __DIR__ . '/templates');
    }
    $vendor = sprintf('Phalcon DevTools (%s)', Version::get());
    print PHP_EOL . Color::colorize($vendor, Color::FG_GREEN, Color::AT_BOLD) . PHP_EOL . PHP_EOL;
    $eventsManager = new EventsManager();
    $eventsManager->attach('command', new CommandsListener());
    $script = new Script($eventsManager);
    $commandsToEnable = array('\\Phalcon\\Commands\\Builtin\\Enumerate', '\\Phalcon\\Commands\\Builtin\\Controller', '\\Phalcon\\Commands\\Builtin\\Model', '\\Phalcon\\Commands\\Builtin\\AllModels', '\\Phalcon\\Commands\\Builtin\\Project', '\\Phalcon\\Commands\\Builtin\\Scaffold', '\\Phalcon\\Commands\\Builtin\\Migration', '\\Phalcon\\Commands\\Builtin\\Webtools');
    foreach ($commandsToEnable as $command) {
        $script->attach(new $command($script, $eventsManager));
    }
Ejemplo n.º 14
0
<?php

use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
try {
    // Register an autoloader
    $loader = new Loader();
    $loader->registerDirs(array('../app/controllers/', '../app/models/', '../app/components'))->register();
    // Create a DI
    $di = new FactoryDefault();
    // Setup the view component
    $di->set('view', function () {
        $view = new View();
        $view->setViewsDir('../app/views/');
        return $view;
    });
    // Setup a base URI so that all generated URIs include the "tutorial" folder
    $di->set('url', function () {
        $url = new UrlProvider();
        $url->setBaseUri('/');
        return $url;
    });
    $di->set('db', function () {
        return new DbAdapter(array("host" => "localhost", "username" => "root", "password" => "vertrigo", "dbname" => "literalLiterature"));
    });
    // Handle the request
    $application = new Application($di);
Ejemplo n.º 15
0
 /**
  * Initializes the loader
  *
  * @param array $options
  */
 protected function initLoader($options = array())
 {
     $config = $this->di['config'];
     // Creates the autoloader
     $loader = new PhLoader();
     $loader->registerDirs(array($config->application->controllersDir, $config->application->modelsDir, $config->application->pluginsDir));
     $loader->register();
     // Composer Autoloading
     //        require_once $config->application->vendorDir . '/autoload.php';
     // Dump it in the DI to reuse it
     $this->di['loader'] = $loader;
 }
Ejemplo n.º 16
0
 /**
  *
  * @param type $options
  */
 protected function initLoader($options = [])
 {
     $config = $this->_di->get('config');
     $loader = new Loader();
     $loader->registerNamespaces(['SysPhalcon\\Controllers' => __DIR__ . '/../shared/controllers', 'SysPhalcon\\Models' => __DIR__ . '/../shared/models', 'SysPhalcon\\Library' => __DIR__ . '/../library', 'SysPhalcon\\Forms' => __DIR__ . '/../forms', 'SysPhalcon\\Plugins' => __DIR__ . '/../plugins', 'SysPhalcon\\Helpers' => __DIR__ . '/../helpers', 'Intranet\\Models' => APP_PATH . '/app/modules/intranet/models', 'Nucleo\\Models' => APP_PATH . '/app/modules/nucleo/models', 'Cnab\\Models' => APP_PATH . '/app/modules/cnab/models', 'Imports\\Models' => APP_PATH . '/app/modules/imports/models', 'Telephony\\Models' => APP_PATH . '/app/modules/telephony/models']);
     $loader->registerDirs([$config->application->pluginsDir, $config->application->libraryDir, $config->application->helpersDir, $config->application->formsDir]);
     $loader->register();
 }
Ejemplo n.º 17
0
 public function run()
 {
     $loader = new Loader();
     $loader->registerDirs(array($this->path() . 'Http' . DIRECTORY_SEPARATOR . 'Controllers' . DIRECTORY_SEPARATOR, $this->path() . 'Http' . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR))->register();
     return $loader;
 }
Ejemplo n.º 18
0
// 根目录定义
define("ROOT_PATH", dirname(__DIR__) . '/');
// 开发模式 TRUE | 线上模式 FALSE
define('DEBUG', TRUE);
try {
    //Create a DI
    $di = new FactoryDefault();
    $di->set('conf', function () {
        $config = new Config(require ROOT_PATH . '/app/config/config.php');
        $config = $config->toArray();
        return $config;
    });
    $config = $di->get('conf');
    //Register an autoloader
    $loader = new Loader();
    $loader->registerDirs(array($config['application']['controller'], $config['application']['libDir'], $config['application']['modelsDir'], $config['application']['logicsDir']))->register();
    //Setup a base URI so that all generated URIs include the "tutorial" folder
    $di->set('url', function () use($config) {
        $url = new UrlProvider();
        $url->setBaseUri($config['application']['baseUri']);
        return $url;
    });
    //Start the session the first time a component requests the session service
    $di->set('session', function () {
        $session = new Files();
        $session->start();
        return $session;
    });
    if (!DEBUG) {
        register_shutdown_function(function () use($config) {
            $errInfo = error_get_last();
Ejemplo n.º 19
0
 protected function initLoader()
 {
     $autoload = static::$config->get('autoload');
     if ($autoload) {
         $loader = new Loader();
         if ($autoload->get('dir') instanceof Config) {
             $loader->registerDirs($autoload->get('dir')->toArray());
         }
         if ($autoload->get('namespace') instanceof Config) {
             $loader->registerNamespaces($autoload->get('namespace')->toArray());
         }
         $loader->register();
     }
 }
Ejemplo n.º 20
0
<?php

use Phalcon\Loader;
/** Composer Autoload */
require_once '../vendor/autoload.php';
$loader = new Loader();
$loader->registerNamespaces(array('Project' => '../application/library/Project'));
$loader->registerDirs(array('../application/plugins'));
$loader->register();
Ejemplo n.º 21
0
<?php

use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Http\Response\Cookies;
use Phalcon\Session\Adapter\Files;
require "../app/config/Config.php";
try {
    // Register an autoloader
    $loader = new Loader();
    $loader->registerDirs(array('../app/controllers/', '../app/models/', '../app/config/', '../app/libraries/'))->register();
    // Create a DI
    $di = new FactoryDefault();
    // return DB config
    $di->setShared('config', function () use($config) {
        return $config;
    });
    // Database
    $di->set('db', function () use($di) {
        $dbconfig = $di->get('config')->get('db')->toArray();
        $db = new DbAdapter($dbconfig);
        return $db;
    });
    // Setup the view component
    $di->set('view', function () {
        $view = new View();
        $view->setViewsDir('../app/views/');
Ejemplo n.º 22
0
<?php

use Phalcon\Loader;
/* loadder settings */
$loader = new Loader();
$loader->registerDirs(array($config->app->modelsDir))->register();
Ejemplo n.º 23
0
 /**
  * Execute Phalcon Developer Tools
  *
  * @param  string             $path The path to the Phalcon Developer Tools
  * @param  string             $ip   Optional IP address for securing Developer Tools
  * @return void
  * @throws \Exception         if Phalcon extension is not installed
  * @throws \Exception         if Phalcon version is not compatible Developer Tools
  * @throws \Phalcon\Exception if Application config could not be loaded
  */
 public static function main($path, $ip = null)
 {
     if (!extension_loaded('phalcon')) {
         throw new \Exception(sprintf("Phalcon extension isn't installed, follow these instructions to install it: %s", Script::DOC_INSTALL_URL));
     }
     if ($ip !== null) {
         self::$ip = $ip;
     }
     if (!defined('TEMPLATE_PATH')) {
         define('TEMPLATE_PATH', $path . '/templates');
     }
     $basePath = dirname(getcwd());
     // Dirs for search config file
     $configDirs = array($basePath . '/config/', $basePath . '/app/config/', $basePath . '/apps/frontend/config/', $basePath . '/apps/backend/config/');
     $readed = false;
     foreach ($configDirs as $configPath) {
         if (file_exists($configPath . 'config.ini')) {
             $config = new ConfigIni($configPath . 'config.ini');
             $readed = true;
             break;
         } else {
             if (file_exists($configPath . 'config.php')) {
                 $config = (include $configPath . 'config.php');
                 if (is_array($config)) {
                     $config = new Config($config);
                 }
                 $readed = true;
                 break;
             }
         }
     }
     if ($readed === false) {
         throw new Exception(sprintf('Configuration file could not be loaded! Scanned dirs: %s', implode(', ', $configDirs)));
     }
     $loader = new Loader();
     $loader->registerDirs(array($path . '/scripts/', $path . '/scripts/Phalcon/Web/Tools/controllers/'));
     $loader->registerNamespaces(array('Phalcon' => $path . '/scripts/'));
     $loader->register();
     if (Version::getId() < Script::COMPATIBLE_VERSION) {
         throw new \Exception(sprintf("Your Phalcon version isn't compatible with Developer Tools, download the latest at: %s", Script::DOC_DOWNLOAD_URL));
     }
     try {
         $di = new FactoryDefault();
         $di->set('view', function () use($path) {
             $view = new View();
             $view->setViewsDir($path . '/scripts/Phalcon/Web/Tools/views/');
             return $view;
         });
         $di->set('config', $config);
         $di->set('url', function () use($config) {
             $url = new Url();
             $url->setBaseUri($config->application->baseUri);
             return $url;
         });
         $di->set('flash', function () {
             return new Flash(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'));
         });
         $di->set('db', function () use($config) {
             if (isset($config->database->adapter)) {
                 $adapter = $config->database->adapter;
             } else {
                 $adapter = 'Mysql';
             }
             if (is_object($config->database)) {
                 $configArray = $config->database->toArray();
             } else {
                 $configArray = $config->database;
             }
             $className = 'Phalcon\\Db\\Adapter\\Pdo\\' . $adapter;
             unset($configArray['adapter']);
             return new $className($configArray);
         });
         self::$di = $di;
         $app = new Application();
         $app->setDi($di);
         echo $app->handle()->getContent();
     } catch (Exception $e) {
         echo get_class($e), ': ', $e->getMessage(), "<br>";
         echo nl2br($e->getTraceAsString());
     } catch (\PDOException $e) {
         echo get_class($e), ': ', $e->getMessage(), "<br>";
         echo nl2br($e->getTraceAsString());
     }
 }
Ejemplo n.º 24
0
<?php

use Phalcon\Loader;
use Phalcon\Mvc\Micro;
use Phalcon\Http\Response;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as PdoMysql;
// use Loader() to autoload our model
$loader = new Loader();
$loader->registerDirs(array(__DIR__ . '/models/'))->register();
$di = new FactoryDefault();
// Set up the database service
$di->set('db', function () {
    return new PdoMysql(array("host" => "127.0.0.1", "username" => "root", "password" => "0000", "dbname" => "phalcapi"));
});
// Create and bind the DI to the application
$app = new Micro($di);
// Define the routes
// Retrieves all robots
$app->get('/api/robots', function () use($app) {
    $phql = "SELECT * FROM Robots ORDER BY name";
    $robots = $app->modelsManager->executeQuery($phql);
    $data = array();
    foreach ($robots as $robot) {
        $data[] = array('id' => $robot->id, 'name' => $robot->name);
    }
    echo json_encode($data);
});
// Searches for robots with $name in their name
$app->get('/api/robots/search/{name}', function ($name) use($app) {
    $phql = "SELECT * FROM Robots WHERE name LIKE :name: ORDER BY name";
Ejemplo n.º 25
0
<?php

use Phalcon\Loader;
use Phalcon\Tag;
use Phalcon\Mvc\Url;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
error_reporting(E_ALL);
ini_set('display_errors', '1');
try {
    // Register an autoloader
    $loader = new Loader();
    $loader->registerDirs(['../app/controllers/', '../app/models/'])->register();
    // Create a DI
    $di = new FactoryDefault();
    // Set the database service
    $di['db'] = function () {
        return new DbAdapter(["host" => "localhost", "username" => "root", "password" => "pass", "dbname" => "jdi-cars"]);
    };
    // Setting up the view component
    $di['view'] = function () {
        $view = new View();
        $view->setViewsDir('../app/views/');
        return $view;
    };
    $di['url'] = function () {
        $url = new Url();
        $url->setBaseUri('/');
        return $url;
Ejemplo n.º 26
0
use Phalcon\Mvc\Application as PhApplication;
$di = new PhDI();
/**
 * Config file
 */
$configFile = (require ROOT_PATH . '/_support/_config/global.php');
$di->set('config', function () use($configFile) {
    return new PhConfig($configFile);
}, true);
/**
 * Autoloader
 */
$di->set('loader', function () use($di) {
    $config = $di['config'];
    $loader = new PhLoader();
    $loader->registerDirs([$config->app_path->dirs]);
    // Register the Library namespace as well as the common module
    // since it needs to always be available
    $loader->registerNamespaces(['PhalconTest\\Models' => $config->app_path->models]);
    $loader->register();
});
/**
 * The URL component is used to generate all kind of urls in the
 * application
 */
$di->set('url', function () use($di) {
    $config = $di['config'];
    $url = new PhUrl();
    $url->setBaseUri($config->app_baseUri);
    return $url;
}, true);
 /**
  * Initializes the loader
  *
  * @param array $options
  */
 protected function initLoader($options = array())
 {
     $config = $this->_di->get('config');
     // Creates the autoloader
     $loader = new PhLoader();
     $loader->registerDirs(array(ROOT_PATH . $config->app->path->controllers, ROOT_PATH . $config->app->path->models, ROOT_PATH . $config->app->path->library));
     // Register the namespace
     $loader->registerNamespaces(array("NDN" => $config->app->path->library));
     $loader->register();
 }
Ejemplo n.º 28
0
<?php

use Phalcon\Loader;
$loader = new Loader();
$loader->registerNamespaces(array('Index' => ROOT_DIR . '/Apps/Index', 'Admin' => ROOT_DIR . '/Apps/Admin', 'Agent' => ROOT_DIR . '/Apps/Agent', 'System' => ROOT_DIR . '/Apps/System', 'App' => ROOT_DIR . '/Apps/App', 'Api' => ROOT_DIR . '/Api'));
$loader->registerDirs(array(ROOT_DIR . '/Apps', ROOT_DIR . '/Api'), true);
$loader->register();
Ejemplo n.º 29
0
<?php

use Phalcon\Loader, Phalcon\DI\FactoryDefault, Phalcon\Mvc\Application, Phalcon\Mvc\View;
$loader = new Loader();
$loader->registerDirs(array('../apps/controllers/', '../apps/models/'))->register();
$di = new FactoryDefault();
// Registering the view component
$di->set('view', function () {
    $view = new View();
    $view->setViewsDir('../apps/views/');
    return $view;
});
try {
    $application = new Application($di);
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Ejemplo n.º 30
0
 public function registerAutoloaders($di)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array('Lininliao\\Frontend\\Library' => ROOT . DS . 'apps' . DS . SITENAME . DS . 'Library', 'Lininliao\\Frontend\\Controllers' => ROOT . DS . 'apps' . DS . SITENAME . DS . 'Controllers', 'Lininliao\\Frontend\\Models' => ROOT . DS . 'apps' . DS . SITENAME . DS . 'Models', 'Lininliao\\Frontend\\Plugins' => ROOT . DS . 'apps' . DS . SITENAME . DS . 'Plugins', 'Lininliao\\Frontend\\Views' => ROOT . DS . 'apps' . DS . SITENAME . DS . 'Views'));
     $loader->registerDirs(array(ROOT . DS . 'apps' . DS . SITENAME . DS . 'Controllers', ROOT . DS . 'apps' . DS . SITENAME . DS . 'Library', ROOT . DS . 'apps' . DS . SITENAME . DS . 'Models', ROOT . DS . 'apps' . DS . SITENAME . DS . 'Plugins', ROOT . DS . 'apps' . DS . SITENAME . DS . 'Views'))->register();
 }