当前位置: 首页>>代码示例>>PHP>>正文


PHP Loader::registerDirs方法代码示例

本文整理汇总了PHP中Phalcon\Loader::registerDirs方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::registerDirs方法的具体用法?PHP Loader::registerDirs怎么用?PHP Loader::registerDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Loader的用法示例。


在下文中一共展示了Loader::registerDirs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: autoloadClass

 /**
  * 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);
     }
 }
开发者ID:aodkrisda,项目名称:phalcon-micro-route-annotations,代码行数:33,代码来源:MicroRouteAnnotations.php

示例2: _initLoader

 /**
  * 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;
 }
开发者ID:nguyenducduy,项目名称:haraapp,代码行数:34,代码来源:Init.php

示例3: registerAutoloaders

 /**
  * 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();
 }
开发者ID:denners777,项目名称:api-phalcon,代码行数:12,代码来源:Module.php

示例4: registerAutoloaders

 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();
 }
开发者ID:lnmtien,项目名称:phalcon-base,代码行数:8,代码来源:Module.php

示例5: initLoader

 /**
  * 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;
 }
开发者ID:enajeeb,项目名称:phalcon-rest-boilerplate,代码行数:13,代码来源:bootstrap.php

示例6: registerAutoloaders

 /**
  * 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();
 }
开发者ID:xw716825,项目名称:work,代码行数:16,代码来源:Module.php

示例7: initLoader

 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;
 }
开发者ID:NavinPanchu,项目名称:phalcon-boilerplate,代码行数:11,代码来源:Unit.php

示例8: __construct

 /**
  * 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);
 }
开发者ID:boiler256,项目名称:mvc,代码行数:21,代码来源:index.php

示例9: registerServices

 /**
  * 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);
 }
开发者ID:silverwolfx10,项目名称:tcc-uhealth,代码行数:20,代码来源:index.php

示例10: registerServices

 /**
  * 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);
 }
开发者ID:boiler256,项目名称:mvc,代码行数:23,代码来源:index.php

示例11: Loader

/**
 * 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
开发者ID:godsoul,项目名称:phalcon_restful_api,代码行数:30,代码来源:index.php

示例12: dirname

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));
    }
开发者ID:ntamvl,项目名称:phalcon-devtools,代码行数:31,代码来源:phalcon.php

示例13: Loader

<?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);
开发者ID:proskills,项目名称:literal-literature,代码行数:31,代码来源:index.php

示例14: initLoader

 /**
  * 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;
 }
开发者ID:hacktm15,项目名称:CityBox,代码行数:17,代码来源:bootstrap.php

示例15: initLoader

 /**
  *
  * @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();
 }
开发者ID:denners777,项目名称:api-phalcon,代码行数:12,代码来源:bootstrap.php


注:本文中的Phalcon\Loader::registerDirs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。