本文整理汇总了PHP中Phalcon\Loader::registerClasses方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::registerClasses方法的具体用法?PHP Loader::registerClasses怎么用?PHP Loader::registerClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Loader
的用法示例。
在下文中一共展示了Loader::registerClasses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerClassMap
/**
* Register class map
* @param array $classMap
* @throws Exception\RuntimeException
* @todo Should cache multi include file into one
*/
protected function registerClassMap(array $classMap)
{
foreach ($classMap as $file) {
$arrClasses = (require $file);
if (!ArrayUtils::isHashTable($arrClasses, true)) {
throw new Exception\RuntimeException('Config autoload for classmap is invalid');
}
if (!empty($arrClasses)) {
$this->loader->registerClasses($arrClasses);
}
}
}
示例2: 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();
}
示例3: 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();
}
示例4: getController
/**
* Helper to load the a controller
*
* @coversNothing
*/
public function getController($name)
{
$loader = new Loader();
$loader->registerClasses(['\\App\\Modules\\Backend\\Controllers\\API\\' . ucfirst($name) . 'Controller' => ROOT_PATH . 'modules/backend/controller/api/'])->register();
$indexCntrl = new \App\Modules\Backend\Controllers\API\IndexController();
$this->assertNotNull($indexCntrl, 'Make sure the index controller could be loaded');
return $indexCntrl;
}
示例5: 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/', 'Tasks' => CLI_PATH . '/tasks/']);
$loader->registerClasses(['__' => VENDOR_PATH . '/Underscore.php']);
$loader->register();
// Autoload vendor dependencies
require_once VENDOR_PATH . '/autoload.php';
$this->di['loader'] = $loader;
}
示例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();
}
示例7: function
*
*/
$di->set('loader', function () use($config) {
$commonDir = $config->path->commonDir;
$modulesDir = $config->path->modulesDir;
$loader = new Loader();
$loader->setExtensions(['php']);
$loader->registerNamespaces(['Webird\\Models' => "{$commonDir}/models", 'Webird\\Forms' => "{$commonDir}/forms", 'Webird\\Plugins' => "{$commonDir}/plugins", 'Webird' => "{$commonDir}/library"]);
$loader->register();
$classes = [];
foreach ($config->app->modules as $moduleName) {
$class = 'Webird\\' . ucfirst($moduleName) . '\\Module';
$path = Module::moduleNameToDir($moduleName) . 'Module.php';
$classes[$class] = $path;
}
$loader->registerClasses($classes, true);
$loader->register();
return $loader;
});
$di->get('loader');
/**
*
*/
$di->setShared('db', function () use($di) {
$config = $di->get('config');
return new DbAdapter(['host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname, 'charset' => $config->database->charset]);
});
/**
*
*/
$di->set('sessionReader', function () use($di) {
示例8: setupClassesAutoloader
/**
* Setups class autoloader
*
* @return array
*/
protected function setupClassesAutoloader()
{
$files = array();
$classes = array();
//browse directories recursively
$directoryIterator = new \RecursiveDirectoryIterator($this->directory);
$regex = isset($this->options['match']) ? $this->options['match'] : '/(.*)\\.php/i';
$iterator = new \RecursiveIteratorIterator($directoryIterator);
foreach ($iterator as $file) {
if ($file->getFileName() == '.' || $file->getFileName() == '..') {
continue;
}
if ($regex && !preg_match($regex, $file->getFileName())) {
continue;
}
//resolves name of class
$className = $this->resolveFileClassName($file);
//collects files and classes
$files[$className] = $file;
$classes[ltrim($className, '\\')] = $file->getPathname();
}
//classes autoloader
$this->loader->registerClasses($classes, true);
$this->loader->register();
return $files;
}
示例9: Loader
*/
$loader = new Loader();
$nameSpaces = array('PhalconRest\\Models' => $config['application']['modelsDir'], 'PhalconRest\\Entities' => $config['application']['entitiesDir'], 'PhalconRest\\Controllers' => $config['application']['controllersDir'], 'PhalconRest\\Exceptions' => $config['application']['exceptionsDir'], 'PhalconRest\\Libraries' => $config['application']['librariesDir'], 'PhalconRest\\Responses' => $config['application']['responsesDir']);
// load Composer Namespaces
$map = (require COMPOSER_PATH . 'composer/autoload_namespaces.php');
foreach ($map as $nameSpace => $path) {
$nameSpace = trim($nameSpace, '\\');
if (!isset($namespaces[$nameSpace])) {
// use the first key in the path array for now....
$nameSpaces[$nameSpace] = $path[0];
}
}
$loader->registerNamespaces($nameSpaces);
// load Composer Classes
$classMap = (require COMPOSER_PATH . 'composer/autoload_classmap.php');
$loader->registerClasses($classMap);
// load Composer Files
// careful with this one since it pollutes the global name space
$autoLoadFilesPath = COMPOSER_PATH . 'composer/autoload_files.php';
if (file_exists($autoLoadFilesPath)) {
$files = (require $autoLoadFilesPath);
foreach ($files as $file) {
require_once $file;
}
}
$loader->register();
// now init Phalcon DI object with services required by the core API
require_once "services.php";
// load logic to bootstrap the web app
if (PHP_SAPI == 'cli') {
require_once 'bootstrap/cli.php';
示例10: Loader
<?php
use Phalcon\Loader;
$loader = new Loader();
/**
* Register Namespaces
*/
$loader->registerNamespaces(['@@namespace@@\\Models' => APP_PATH . '/common/models/', '@@namespace@@' => APP_PATH . '/common/library/']);
/**
* Register module classes
*/
$loader->registerClasses(['@@namespace@@\\Modules\\Frontend\\Module' => APP_PATH . '/modules/frontend/Module.php', '@@namespace@@\\Modules\\Cli\\Module' => APP_PATH . '/modules/cli/Module.php']);
$loader->register();
示例11: setupServiceProvidersAutoloader
/**
* Registers classes that contains services providers
*
* @param string $inputDirectory
* @param array $services
* @internal
*/
private function setupServiceProvidersAutoloader($inputDirectory, array $services)
{
//creates the autoloader
$loader = new Loader();
//setup default path when is not defined
foreach ($services as $className => $path) {
if (!$path) {
$services[$className] = $inputDirectory . sprintf('%s.php', $className);
}
}
$loader->registerClasses($services, true);
$loader->register();
}
示例12: 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\Postgresql as DbAdapter;
try {
// Register an autoloader
$loader = new Loader();
$loader->registerDirs(array('../app/controllers/', '../app/models/', '../app/helpers/'))->register();
$loader->registerClasses(array("BLTI" => "../app/library/ims_lti/blti.php", "LTIContext" => "../app/library/LTIContext.php"));
// Create a DI
$di = new FactoryDefault();
// Load configuration file
$config = new \Phalcon\Config\Adapter\Php("../app/config/config.php");
// Store it in the Di container
$di->setShared("config", $config);
// Setup the LTI context (this takes care of starting the session, too)
$context = LTIContext::getContext($config);
$di->setShared("ltiContext", $context);
// Now in views and controllers, all we have to do is check if this context is valid
// Get in the right time zone
date_default_timezone_set("America/Denver");
// Setup the database service
$di->set('db', function () use($config) {
return new DbAdapter(array("host" => $config->visualization_database->host, "dbname" => $config->visualization_database->dbname, "username" => $config->visualization_database->username, "password" => $config->visualization_database->password));
});
// Setup the view component
$di->set('view', function () {
示例13: registerClasses
public function registerClasses(array $classes, $merge = false)
{
return parent::registerClasses($classes, $merge);
}
示例14: initLoader
/**
* 初始化 loader
* @param array $config 配置数组
*/
public function initLoader(array $config)
{
$loader = new Loader();
// 读取配置中的namespace
$loaderVendorNamespaces = function ($arr, $config) {
foreach ($config as $k => $v) {
$k = trim($k, '\\');
if (!isset($arr[$k])) {
$dir = '/' . str_replace('\\', '/', $k) . '/';
$arr[$k] = implode($dir . ';', $v) . $dir;
}
}
return $arr;
};
$namespaces = isset($config['namespace']) ? $config['namespace'] : [];
if (isset($config['vendorDir'])) {
try {
$vendorDir = $config['vendorDir'];
// 加载vondor中的namespaces
$namespaces = $loaderVendorNamespaces($namespaces, require $vendorDir . '/composer/autoload_namespaces.php');
$namespaces = $loaderVendorNamespaces($namespaces, require $vendorDir . '/composer/autoload_psr4.php');
// 加载vondor中的class
$vendorClassMap = (require $vendorDir . '/composer/autoload_classmap.php');
$loader->registerClasses($vendorClassMap);
} catch (\Exception $e) {
}
}
$loader->registerNamespaces($namespaces);
if (isset($config['loader']) && $config['classDirs']) {
$loader->registerDirs($config['classDirs']);
}
$loader->register();
}
示例15: define
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Loader;
defined('ROOT_PATH') or define('ROOT_PATH', dirname(__DIR__));
isset($_SERVER['PHWOOLCON_ROOT_PATH']) or $_SERVER['PHWOOLCON_ROOT_PATH'] = ROOT_PATH;
isset($_SERVER['PHWOOLCON_CONFIG_PATH']) or $_SERVER['PHWOOLCON_CONFIG_PATH'] = ROOT_PATH . '/app/config';
isset($_SERVER['PHWOOLCON_MIGRATION_PATH']) or $_SERVER['PHWOOLCON_MIGRATION_PATH'] = ROOT_PATH . '/bin/migrations';
if (!extension_loaded('phalcon')) {
echo $error = 'Extension "phalcon" not detected, please install or activate it.';
throw new RuntimeException($error);
}
// The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
$di = new FactoryDefault();
if (!is_file($includes = ROOT_PATH . '/vendor/composer/autoload_phalcon_files.php')) {
echo $error = sprintf('Autoload not ready, please run command "%s/bin/dump-autoload" first.', ROOT_PATH);
throw new UnexpectedValueException($error);
}
include $includes;
// Register class loader
$loader = new Loader();
$loader->registerClasses(include ROOT_PATH . '/vendor/composer/autoload_classmap.php')->registerNamespaces(include ROOT_PATH . '/vendor/composer/autoload_phalcon_psr4.php')->register();
$di->setShared('loader', $loader);