本文整理汇总了PHP中ClassLoader::load方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::load方法的具体用法?PHP ClassLoader::load怎么用?PHP ClassLoader::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Loads the directory recursively
*
* @param string $specDir
* @param array $ignore
* @return array
*/
public function load($specDir, $ignore = array())
{
$ignore = $this->lookForIgnoreConfig($specDir, $ignore);
$directory = new \DirectoryIterator($specDir);
$loaded = array();
foreach ($directory as $file) {
if ($file->isDot()) {
continue;
}
if ($this->fileIsNotInIgnoreList($file, $ignore)) {
if ($file->isDir()) {
$loaded = array_merge($loaded, $this->load($file->getRealpath(), $ignore));
} else {
$example = parent::load($file->getRealpath());
if ($example !== false && $example !== array(false)) {
if (!is_array($example)) {
$example = array($example);
}
$loaded = array_merge($loaded, $example);
}
}
}
}
return $loaded;
}
示例2: __autoload
function __autoload($className)
{
static $stat;
if (!$stat) {
$stat = $_REQUEST['stat'];
}
$start = microtime(true);
ClassLoader::load($className);
$elapsed = microtime(true) - $start;
if (empty($GLOBALS['ClassLoaderTime'])) {
$GLOBALS['ClassLoaderTime'] = $GLOBALS['ClassLoaderCount'] = 0;
}
$GLOBALS['ClassLoaderTime'] += $elapsed;
$GLOBALS['ClassLoaderCount']++;
}
示例3: setUp
public function setUp()
{
parent::setUp();
// enable route filters
$this->app['router']->enableFilters();
// create an artisan object for running migrations
$artisan = $this->app->make('artisan');
// run the migrations to create Sentry 2 tables
$artisan->call('migrate', array('--database' => 'testbench', '--path' => '../vendor/cartalyst/sentry/src/migrations'));
// run our migrations to update the Sentry 2 users table
$artisan->call('migrate', array('--database' => 'testbench', '--path' => 'migrations'));
// seed our database tables
$artisan->call('migrate', array('--database' => 'testbench', '--path' => '../tests/seeds'));
// Load models
ClassLoader::addDirectories(array(realpath(__DIR__ . '/models')));
ClassLoader::load('Foo');
ClassLoader::load('Bar');
ClassLoader::load('Baz');
}
示例4: app_path
<?php
/*
|--------------------------------------------------------------------------
| Register The Laravel Class Loader
|--------------------------------------------------------------------------
|
| In addition to using Composer, you may use the Laravel class loader to
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
ClassLoader::load(app_path() . '/models/Subtask.php');
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a rotating log file setup which creates a new file each day.
|
*/
$logFile = 'log-' . php_sapi_name() . '.txt';
Log::useDailyFiles(storage_path() . '/logs/' . $logFile);
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
示例5: phpUtilAutoload
/**
* Automatically load classes' files.
*
* @param className the class name to be loaded.
*/
function phpUtilAutoload($className)
{
static $classLoader = null;
// Created just once
if (!isset($classLoader)) {
// File to store the directories list
define('SUB_DIR_FILE', 'subdir.lst');
$subDirs = array();
if (file_exists(SUB_DIR_FILE)) {
// Load the subdirectories from the file
$content = file_get_contents(SUB_DIR_FILE);
$subDirs = explode(PHP_EOL, $content);
} else {
// Save the subdirectories to the file
$subDirs = DirUtil::allSubDirs('.');
$content = implode(PHP_EOL, $subDirs);
file_put_contents(SUB_DIR_FILE, $content, LOCK_EX);
}
// Here you can configure other file extensions. Example:
// $classLoader = new ClassLoader( $subDirs,
// array( '.php', '.class.php' ) );
$classLoader = new ClassLoader($subDirs);
}
// Load the class
$classLoader->load($className);
}
示例6: function
}
}
});
Event::listen('APL.core.prepare', function () use($APLExtensions) {
foreach ($APLExtensions as $Extension) {
$full_class = "WebAPL\\" . $Extension;
$full_class::__init();
class_alias($full_class, $Extension);
}
});
Event::listen('APL.modules.load', function () {
Event::fire('APL.core.load');
Event::fire('APL.core.prepare');
Module::where('enabled', '1')->get()->each(function ($module) {
ClassLoader::addDirectories(app_path() . '/modules/' . $module->extension . '/');
ClassLoader::load($module->extension);
Modules::addInstance($module->extension);
});
});
$clear_cache = FALSE;
Event::listen(['eloquent.sav*', 'eloquent.upd*', 'eloquent.del*', 'eloquent.creat*'], function () use(&$clear_cache) {
$clear_cache = TRUE;
});
App::shutdown(function () use(&$clear_cache) {
if ($clear_cache) {
File::deleteDirectory($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/cache/');
@unlink($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/meta/services.json');
Cache::flush();
}
});
App::before(function () {
示例7: dirname
<?php
require_once dirname(__DIR__) . '/bootstrap.php';
require_once PATH_VENDOR_ROOT . '/Slim/Slim.php';
$app = new Slim();
$app->config('templates.path', dirname(__DIR__) . '/templates');
$app->get('/', function () use($app) {
$app->render('index.html', array());
});
$app->get('/mecab', function () use($app) {
$sentence = $app->request()->get('s');
$cl = new ClassLoader();
$ret = $cl->load('Mecab');
$mecab = new Mecab();
/*
$mecab_options = array(
'-u' => PATH_RESOURCE_ROOT . '/word.dic',
);
*/
$ret = $mecab->parseToNode($sentence, $mecab_options);
$app->response()->header('Content-Type', 'application/json; charset=utf-8');
$app->response()->body(json_encode($ret));
});
$app->run();