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


PHP Loader::registerNamespaces方法代码示例

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


在下文中一共展示了Loader::registerNamespaces方法的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: setUp

 public function setUp()
 {
     parent::setUp();
     $this->loader = $this->di->getLoader();
     $strModule = 'App\\Modules\\Api';
     $strModuleDir = $this->di->getConfig()->application->modulesDir . DIRECTORY_SEPARATOR . 'api';
     $this->loader->registerNamespaces(array($strModule => $strModuleDir), true);
     $this->module = new Module();
 }
开发者ID:rcmonitor,项目名称:abboom_phalcon_code_example,代码行数:9,代码来源:VersionLoaderTest.php

示例3: registerAutoloaders

 /**
  * Register the autoloader specific to the current module
  * @access public
  * @return \Phalcon\Loader\Loader()
  */
 public function registerAutoloaders()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Modules\\Backend\\Controllers' => $this->_config['application']['controllersBack'], 'Modules\\Backend\\Forms' => $this->_config['application']['formsBack'], 'Models' => $this->_config['application']['modelsDir'], 'Helpers' => $this->_config['application']['helpersDir'], 'Libraries' => $this->_config['application']['libraryDir'], 'Plugins' => $this->_config['application']['pluginsDir']]);
     $loader->register();
     if (APPLICATION_ENV == 'development') {
         $namespaces = array_merge($loader->getNamespaces(), ['Phalcon\\Utils' => APP_PATH . '/Libraries/PrettyExceptions/Library/Phalcon/Utils']);
         $loader->registerNamespaces($namespaces);
         // call pretty loader
         set_error_handler(function ($errorCode, $errorMessage, $errorFile, $errorLine) {
             $p = new \Phalcon\Utils\PrettyExceptions();
             $p->handleError($errorCode, $errorMessage, $errorFile, $errorLine);
         });
     }
 }
开发者ID:stanislav-web,项目名称:phalcon-development,代码行数:20,代码来源:Module.php

示例4: setDi

function setDi()
{
    $di = new FactoryDefault();
    $di['router'] = function () use($di) {
        $router = new Router();
        $router->setDefaultModule('mobimall');
        return $router;
    };
    $di['url'] = function () {
        $url = new UrlResolver();
        $url->setBaseUri('/');
        return $url;
    };
    $di['session'] = function () {
        $session = new SessionAdapter();
        // $session->start();
        return $session;
    };
    $loader = new Loader();
    $loader->registerNamespaces(array('Mall\\Mdu' => __DIR__ . '/../apps/mdu'));
    $sysConfig = (include __DIR__ . '/../config/sysconfig.php');
    $di['sysconfig'] = function () use($sysConfig) {
        return $sysConfig;
    };
    $loader->register();
    return $di;
}
开发者ID:nicklos17,项目名称:littlemall,代码行数:27,代码来源:index.php

示例5: _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

示例6: registerAutoloaders

 public function registerAutoloaders()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Admin\\Controllers' => ADMINROOT . '/controllers/', 'Admin\\Fields' => ADMINROOT . '/fields/'], true);
     $loader->registerClasses(['AutoAdmin\\Module' => ADMINROOT . '/../autoadmin/module.php'], true);
     $loader->register();
 }
开发者ID:moaljazaery,项目名称:phalcon-module-admin,代码行数:7,代码来源:module.php

示例7: registerNamespace

 private function registerNamespace()
 {
     $loader = new Loader();
     $this->namespace = array_merge($this->namespace, ['Common\\Util' => './module/common/util/', 'Common\\Services' => './module/common/services/']);
     $loader->registerNamespaces($this->namespace);
     $loader->register();
 }
开发者ID:Jhorzyto,项目名称:phalcon-rest-api-module,代码行数:7,代码来源:app.php

示例8: registerAutoloaders

 public function registerAutoloaders(DiInterface $di = null)
 {
     $l = new Loader();
     $dir = __DIR__;
     $l->registerNamespaces([self::$ctrlnamespace => __DIR__ . '/']);
     $l->register();
 }
开发者ID:logikostech,项目名称:core,代码行数:7,代码来源:Module.php

示例9: registerAutoloaders

 /**
  * Register a specific autoloader for the module
  */
 public function registerAutoloaders(DiInterface $di = NULL)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array('Ecommerce\\Admin\\Controllers' => '../apps/admin/controllers/', 'Ecommerce\\Admin\\Models' => '../apps/admin/models/', 'Ecommerce\\Admin\\Forms' => '../apps/admin/forms/', 'Ecommerce\\Admin\\Helpers' => '../apps/admin/helpers/', 'Ecommerce\\Loja\\Helpers' => '../apps/loja/helpers/'));
     require '../apps/loja/vendor/autoload.php';
     $loader->register();
 }
开发者ID:denners777,项目名称:phalcon_ecommerce,代码行数:10,代码来源:Module.php

示例10: registerAutoloaders

 /**
  * Registers an autoloader related to the module
  *
  * @param DiInterface $di
  */
 public function registerAutoloaders(DiInterface $di = null)
 {
     $config = $this->config;
     $debug = $this->debug;
     $namespace = substr(get_class($this), 0, strripos(get_class($this), '\\'));
     $baseDir = $this::DIR . '/';
     $regs = [$namespace => $baseDir];
     $loader = new Loader();
     // 配置中的名字空间设置
     $namespaceConfig = $config->offsetExists('namespaces') ? $config->namespaces->toArray() : [];
     foreach ($namespaceConfig as $n => $d) {
         $regs[$n] = $d;
     }
     // 检查 controllers 和 models是否存在
     $moduleControllers = $namespace . '\\Controllers';
     $moduleModels = $namespace . '\\Models';
     if (!isset($regs[$moduleControllers])) {
         $regs[$moduleControllers] = $baseDir . 'controllers/';
     }
     if (!isset($regs[$moduleModels])) {
         $regs[$moduleModels] = $baseDir . 'models/';
     }
     $loader->registerNamespaces($regs);
     $loader->register();
 }
开发者ID:c78702505,项目名称:phalcon-phputils,代码行数:30,代码来源:ModuleBase.php

示例11: register

 /**
  * Auto register namespace and class map
  * @throws Exception\RuntimeException
  * @todo Should cache register classmap
  */
 public function register()
 {
     $moduleHandler = $this->diFactory->get('moduleHandler');
     $autoloadConf = $moduleHandler->getModulesAutoloadConfig();
     if (isset($autoloadConf['namespaces'])) {
         if (!ArrayUtils::isHashTable($autoloadConf['namespaces'])) {
             throw new Exception\RuntimeException('Config autoload for namespace is invalid');
         }
         $this->loader->registerNamespaces($autoloadConf['namespaces']);
     }
     if (isset($autoloadConf['classmap'])) {
         $this->registerClassMap($autoloadConf['classmap']);
     }
     $this->loader->register();
     return $this;
 }
开发者ID:tmquang6805,项目名称:phalex,代码行数:21,代码来源:Autoloader.php

示例12: registerAutoloaders

 /**
  * Registers the module auto-loader
  */
 public function registerAutoloaders()
 {
     $config = (include __DIR__ . "/../../config/constants.php");
     $loader = new Loader();
     $loader->registerNamespaces(array('App\\Modules\\Frontend\\Controllers' => __DIR__ . '/controllers/', 'App\\Models\\Entities' => $config->application->modelsEntitiesDir, 'App\\Models\\Services' => $config->application->modelsServicesDir, 'App\\Models\\Repositories' => $config->application->modelsRepositoriesDir));
     $loader->register();
 }
开发者ID:ariborneo,项目名称:phalcon-restful,代码行数:10,代码来源:Module.php

示例13: registerAutoloaders

 /**
  * Registers the module auto-loader
  */
 public function registerAutoloaders(\Phalcon\DiInterface $di = null)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array('HaiQuan\\Frontend\\Controllers' => __DIR__ . '/controllers/', 'HaiQuan\\Backend\\Models' => __DIR__ . '../../backend/models/', 'library' => __DIR__ . '/../../library/', 'Facebook' => __DIR__ . '/../../library/Facebook', 'Minigame' => __DIR__ . '/../../library/Minigame', 'datacenter' => __DIR__ . '/../../datacenter/', 'payment' => __DIR__ . '/../../payment/', 'event' => __DIR__ . '/../../library/Event/'));
     $loader->registerClasses(array("Google_Client" => __DIR__ . '/../../library/Google/src/Google/Client.php'));
     $loader->register();
 }
开发者ID:nbtai,项目名称:haiquan,代码行数:10,代码来源:Module.php

示例14: registerServices

 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 public function registerServices()
 {
     $di = new FactoryDefault();
     $loader = new Loader();
     $namespaces = [];
     $map = (require_once __DIR__ . '/../autoload_namespaces.php');
     foreach ($map as $k => $values) {
         $k = trim($k, '\\');
         if (!isset($namespaces[$k])) {
             $dir = '/' . str_replace('\\', '/', $k) . '/';
             $namespaces[$k] = implode($dir . ';', $values) . $dir;
         }
     }
     $loader->registerNamespaces($namespaces);
     $loader->register();
     /**
      * Register a router
      */
     $di->set('router', function () {
         $router = new Router();
         $router->setDefaultModule('frontend');
         //set frontend routes
         $router->mount(new FrontendRoutes());
         //
         return $router;
     });
     $this->setDI($di);
 }
开发者ID:adrianeavaz,项目名称:manager.io,代码行数:31,代码来源:Application.php

示例15: registerAutoloaders

 public function registerAutoloaders()
 {
     // echo __DIR__;exit;
     $loader = new Loader();
     $loader->registerNamespaces(array('Modules\\Frontend\\Controllers' => __DIR__ . '/controllers/', 'Modules\\Frontend\\Models' => __DIR__ . '/models/', 'Modules\\Backend\\Controllers' => __DIR__ . '/../backend/controllers/'));
     $loader->register();
 }
开发者ID:hoangnghia,项目名称:it102,代码行数:7,代码来源:Module.php


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