本文整理汇总了PHP中Zend\Loader\StandardAutoloader类的典型用法代码示例。如果您正苦于以下问题:PHP StandardAutoloader类的具体用法?PHP StandardAutoloader怎么用?PHP StandardAutoloader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StandardAutoloader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Calls all init functions of the WCF class.
*/
public function __construct()
{
// add autoload directory
self::$autoloadDirectories['wcf'] = WCF_DIR . 'lib/';
// define tmp directory
if (!defined('TMP_DIR')) {
define('TMP_DIR', FileUtil::getTempFolder());
}
// register additional autoloaders
require_once WCF_DIR . 'lib/system/api/phpline/phpline.phar';
require_once WCF_DIR . 'lib/system/api/zend/Loader/StandardAutoloader.php';
$zendLoader = new ZendLoader(array(ZendLoader::AUTOREGISTER_ZF => true));
$zendLoader->register();
$argv = new ArgvParser(array('packageID=i' => ''));
$argv->setOption(ArgvParser::CONFIG_FREEFORM_FLAGS, true);
$argv->parse();
define('PACKAGE_ID', $argv->packageID ?: 1);
// disable benchmark
define('ENABLE_BENCHMARK', 0);
// start initialization
$this->initDB();
$this->loadOptions();
$this->initSession();
$this->initLanguage();
$this->initTPL();
$this->initCoreObjects();
$this->initApplications();
// the destructor registered in core.functions.php will only call the destructor of the parent class
register_shutdown_function(array('wcf\\system\\CLIWCF', 'destruct'));
$this->initArgv();
$this->initPHPLine();
$this->initAuth();
$this->checkForUpdates();
$this->initCommands();
}
示例2: setUp
public function setUp()
{
if (!class_exists('Archive_Tar')) {
$autoloader = new StandardAutoloader();
$autoloader->setFallbackAutoloader(true);
if (!$autoloader->autoload('Archive_Tar')) {
$this->markTestSkipped('This filter needs PEARs Archive_Tar');
}
}
$files = array(dirname(__DIR__) . '/_files/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second', dirname(__DIR__) . '/_files/_compress/Compress/First/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First', dirname(__DIR__) . '/_files/_compress/Compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress', dirname(__DIR__) . '/_files/_compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress', dirname(__DIR__) . '/_files/compressed.tar');
foreach ($files as $file) {
if (file_exists($file)) {
if (is_dir($file)) {
rmdir($file);
} else {
unlink($file);
}
}
}
if (!file_exists(dirname(__DIR__) . '/_files/Compress/First/Second')) {
mkdir(dirname(__DIR__) . '/_files/Compress/First/Second', 0777, true);
file_put_contents(dirname(__DIR__) . '/_files/Compress/First/Second/zipextracted.txt', 'compress me');
file_put_contents(dirname(__DIR__) . '/_files/Compress/First/zipextracted.txt', 'compress me');
file_put_contents(dirname(__DIR__) . '/_files/Compress/zipextracted.txt', 'compress me');
}
}
示例3: register
public static function register()
{
/**
* Register ModSync namespace
*/
$autoLoader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$autoLoader->registerNamespace('ModSync', Base::getCoreComponentsDir() . DIRECTORY_SEPARATOR . __NAMESPACE__);
$autoLoader->register();
/**
* Register all other namespaces
*/
$components = new DirectoryIterator(Base::getCoreComponentsDir());
foreach ($components as $component) {
if ($component->isDot()) {
continue;
}
if ($component->getFilename() == 'ModSync') {
continue;
}
$componentFile = new SplFileInfo($component->getPathname() . DIRECTORY_SEPARATOR . 'Component' . DIRECTORY_SEPARATOR . 'Component.php');
if ($componentFile->isFile()) {
$autoLoader->registerNamespace($component->getFilename(), $component->getPathname());
}
}
}
示例4: StandardAutoloader
<?php
use Zend\Loader\StandardAutoloader;
chdir(dirname(__DIR__));
include 'init_autoloader.php';
$loader = new StandardAutoloader();
$loader->registerNamespace('ZfDealsTest', __DIR__ . '/ZfDealsTest');
$loader->register();
Zend\Mvc\Application::init(include 'config/application.config.php');
示例5: dirname
<?php
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\Loader\StandardAutoloader;
chdir(__DIR__);
$previousDir = '.';
while (!file_exists('config/application.config.php')) {
$dir = dirname(`pwd`);
if ($previousDir === $dir) {
throw new RuntimeException('Unable to locate "config/application.config.php":' . ' is SxMail in a sub-directory of your application skeleton?');
}
$previousDir = $dir;
chdir($dir);
}
if (!@(include_once __DIR__ . '/../../vendor/autoload.php') && !@(include_once __DIR__ . '/../../../autoload.php')) {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
}
if (!($config = @(include __DIR__ . '/TestConfiguration.php'))) {
$config = (require __DIR__ . '/TestConfiguration.php.dist');
}
$loader = new StandardAutoloader();
$loader->registerNamespace('SxMail', __DIR__ . '/../src/SxMail');
$loader->registerNamespace('SxMailTest', __DIR__ . '/SxMailTest');
$loader->register();
$serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array()));
$serviceManager->setService('ApplicationConfig', $config);
/* @var $moduleManager \Zend\ModuleManager\ModuleManager */
$moduleManager = $serviceManager->get('ModuleManager');
$moduleManager->loadModules();
示例6: getenv
$libPath = getenv('LIB_PATH') ? getenv('LIB_PATH') : __DIR__ . '/../library';
if (!is_dir($libPath)) {
// Try to load StandardAutoloader from include_path
if (false === (include 'Zend/Loader/StandardAutoloader.php')) {
echo "Unable to locate autoloader via include_path; aborting" . PHP_EOL;
exit(2);
}
} else {
// Try to load StandardAutoloader from library
if (false === (include $libPath . '/Zend/Loader/StandardAutoloader.php')) {
echo "Unable to locate autoloader via library; aborting" . PHP_EOL;
exit(2);
}
}
// Setup autoloading
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$rules = array('help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write plugin map file; if not provided, assumes "plugin_classmap.php" in library directory', 'append|a' => 'Append to plugin map file if it exists', 'overwrite|w' => 'Whether or not to overwrite existing autoload file');
try {
$opts = new Console\Getopt($rules);
$opts->parse();
} catch (Console\Exception\RuntimeException $e) {
echo $e->getUsageMessage();
exit(2);
}
if ($opts->getOption('h')) {
echo $opts->getUsageMessage();
exit;
}
$path = $libPath;
if (array_key_exists('PWD', $_SERVER)) {
示例7: testAutoloadsNamespacedClassesWithUnderscores
public function testAutoloadsNamespacedClassesWithUnderscores()
{
$loader = new StandardAutoloader();
$loader->registerNamespace('ZendTest\\UnusualNamespace', __DIR__ . '/TestAsset');
$loader->autoload('ZendTest\\UnusualNamespace\\Name_Space\\Namespaced_Class');
$this->assertTrue(class_exists('ZendTest\\UnusualNamespace\\Name_Space\\Namespaced_Class', false));
}
示例8: testRegisterRegistersCallbackWithSplAutoload
public function testRegisterRegistersCallbackWithSplAutoload()
{
$loader = new StandardAutoloader();
$loader->register();
$loaders = spl_autoload_functions();
$this->assertTrue(count($this->loaders) < count($loaders));
$test = array_pop($loaders);
$this->assertEquals(array($loader, 'autoload'), $test);
}
示例9: __construct
/**
* Setup autoloader. Phrozn uses Zend Framework 2 autoloader.
*
* @return void
*/
private function __construct()
{
if (strpos('@PHP-BIN@', '@PHP-BIN') === 0) {
$base = dirname(__FILE__) . '/';
set_include_path($base . PATH_SEPARATOR . get_include_path());
} else {
$base = '@PEAR-DIR@/Phrozn/';
}
require_once $base . 'Vendor/Zend/Loader/StandardAutoloader.php';
$loader = new Loader();
$loader->registerNamespace('Zend', $base . 'Vendor/Zend')->registerNamespace('Phrozn', $base)->registerNamespace('Symfony', $base . 'Vendor/Symfony')->registerNamespace('Twig', $base . 'Vendor/Twig')->setFallbackAutoloader(true)->register();
// allow to use plugins from project's .phrozn/plugins
$plugins = getcwd();
if (strpos($plugins, '.phrozn') === false) {
$plugins .= '/.phrozn';
}
$plugins .= '/plugins/';
if (is_dir($plugins)) {
$loader->registerNamespace('PhroznPlugin', $plugins);
}
$this->loader = $loader;
}
示例10: registerAddtionalNamespace
/**
* @param StandardAutoloader &$loader
* @return StandardAutoloader $loader
*/
protected static function registerAddtionalNamespace(StandardAutoloader &$loader) : StandardAutoloader
{
$loader->registerNamespace('Gz3Base\\Test', __DIR__);
return $loader;
}
示例11: define
<?php
define("__FORM__", "Application\\Form\\Type\\");
define("__ENTITY__", "Application\\Model\\Entity\\");
use Silex\Application;
use Zend\Loader\StandardAutoloader;
use Zend\Loader\ClassMapAutoloader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Loader\YamlFileLoader;
$standarAutoloader = new StandardAutoloader();
$classmapAutoloader = new ClassMapAutoloader();
$standarAutoloader->registerNamespaces(array('Application\\' => __DIR__ . '/../'));
$classmapAutoloader->registerAutoloadMap(array('PHPExcel' => __DIR__ . '/../../lib/excel/PHPExcel.php', 'PHPMailer' => __DIR__ . '/../../lib/mailer/phpmailer.php', 'SMTP' => __DIR__ . '/../../lib/mailer/class.smtp.php', 'vcalendar' => __DIR__ . '/../../lib/calendar/ical/iCalcreator.class.php'));
$standarAutoloader->register();
$classmapAutoloader->register();
$app["debug"] = true;
$c = new \vcalendar(array('unique_id' => $_SERVER['HTTP_HOST']));
$t =& $c->newComponent('vtodo');
$t->setProperty('dtstart', '19970415T133000 GMT');
$t->setProperty('due', '19970416T045959 GMT');
$t->setProperty('summary', '1996 Income Tax Preparation');
$t->setProperty('class', 'CONFIDENTIAL');
$t->setProperty('categories', 'FAMILY');
$t->setProperty('categories', 'FINANCE');
$t->setProperty('priority', 1);
$t->setProperty('status', 'NEEDS-ACTION');
$str = $c->createCalendar();
$calendarPath = __DIR__ . '/../tmp/Calendar';
file_put_contents($calendarPath . '/sample.ics', $str);
//echo $str;
示例12: registerEntityFilesNamespace
/**
* @param string $namespace
* @param string $namespaceDirectory
*/
protected function registerEntityFilesNamespace($namespace, $namespaceDirectory)
{
$loader = new StandardAutoloader();
$loader->registerNamespace($namespace, $namespaceDirectory);
$loader->register();
}
示例13: chdir
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Setup autoloading
require 'vendor/autoload.php';
require 'module/Debug.php';
use Zend\Loader\StandardAutoloader;
$autoloader = new StandardAutoloader();
$autoloader->registerNamespace('ApplicationTest', __DIR__ . '/ApplicationTest/');
$autoloader->registerNamespace('TheodiaTest', __DIR__ . '/TheodiaTest/');
$autoloader->register();
// All tests always execute with a mocked 'now' time
$myClassReflection = new \ReflectionClass(Application\Utility::class);
$nowProperty = $myClassReflection->getProperty('now');
$nowProperty->setAccessible(true);
$nowProperty->setValue(null, new \DateTimeImmutable('2015-01-02T03:04:00', new \DateTimeZone('UTC')));
示例14: StandardAutoloader
<?php
use Zend\Loader\StandardAutoloader;
require_once '../../../zendframework/zendframework/library/Zend/Loader/StandardAutoloader.php';
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->registerNamespace('Skpd\\Bootstrap\\', '../src');
$loader->register();
$view = new \Zend\View\Renderer\PhpRenderer();
$view->getHelperPluginManager()->setInvokableClass('form', 'Skpd\\Bootstrap\\Form\\View\\Helper\\Form');
$view->getHelperPluginManager()->setInvokableClass('formColor', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormColor');
$view->getHelperPluginManager()->setInvokableClass('formDateTime', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormDateTime');
$view->getHelperPluginManager()->setInvokableClass('formEmail', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormEmail');
$view->getHelperPluginManager()->setInvokableClass('formFile', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormFile');
$view->getHelperPluginManager()->setInvokableClass('formInput', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormInput');
$view->getHelperPluginManager()->setInvokableClass('formMonth', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormMonth');
$view->getHelperPluginManager()->setInvokableClass('formNumber', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormNumber');
$view->getHelperPluginManager()->setInvokableClass('formPassword', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormPassword');
$view->getHelperPluginManager()->setInvokableClass('formRow', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormRow');
$view->getHelperPluginManager()->setInvokableClass('formSelect', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormSelect');
$view->getHelperPluginManager()->setInvokableClass('formTel', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormTel');
$view->getHelperPluginManager()->setInvokableClass('formText', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormText');
$view->getHelperPluginManager()->setInvokableClass('formTextArea', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormTextarea');
$view->getHelperPluginManager()->setInvokableClass('formUrl', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormUrl');
$view->getHelperPluginManager()->setInvokableClass('formCollection', 'Skpd\\Bootstrap\\Form\\View\\Helper\\FormCollection');
$view->getHelperPluginManager()->setInvokableClass('formLabel', 'Zend\\Form\\View\\Helper\\FormLabel');
$view->getHelperPluginManager()->setInvokableClass('formElement', 'Zend\\Form\\View\\Helper\\FormElement');
$view->getHelperPluginManager()->setInvokableClass('formElementErrors', 'Zend\\Form\\View\\Helper\\FormElementErrors');
$view->getHelperPluginManager()->setInvokableClass('formCheckbox', 'Zend\\Form\\View\\Helper\\FormCheckbox');
$view->getHelperPluginManager()->setInvokableClass('formSubmit', 'Zend\\Form\\View\\Helper\\FormSubmit');
$view->getHelperPluginManager()->setInvokableClass('formButton', 'Zend\\Form\\View\\Helper\\FormButton');
$view->getHelperPluginManager()->setInvokableClass('headScript', 'Zend\\View\\Helper\\HeadScript');
示例15: testCanActAsFallbackAutoloader
/**
* borrowed from Zend\Loader\StandardAutoloader
*/
public function testCanActAsFallbackAutoloader()
{
$loader = new StandardAutoloader();
$loader->setFallbackAutoloader(true);
set_include_path(__DIR__ . '/TestAsset/' . PATH_SEPARATOR . $this->includePath);
$loader->autoload('TestNamespace\TestProvider');
$loader->autoload('TestNamespace\TestInvalidProvider');
//initialize ini
$ini = __DIR__. '/_files/enable.ini';
file_put_contents($ini, '');
$clientConfig = new ClientConfig;
$clientConfig->setConfigFilePath($ini);
$this->_registry->setConfig($clientConfig);
$config = $this->_configProvider;
// Test enable provider
try {
$config->enableProvider('TestNamespace\TestInvalidProvider');
$this->fail('RuntimeException was expected but not thrown');
} catch (RuntimeException $re) {
}
$config->enableProvider('TestNamespace\TestProvider');
$configs = $clientConfig->basicloader->classes;
$this->assertEquals('TestNamespace\TestProvider', $configs->current());
// Test disable provider
try {
$config->disableProvider('TestNamespace\TestInvalidProvider');
$this->fail('RuntimeException was expected but not thrown');
} catch (RuntimeException $re) {
}
$config->disableProvider('TestNamespace\TestProvider');
$this->assertEmpty($configs->current(), 'No config setting will exists');
/**
* manifest test
*/
$loader->autoload('TestNamespace\TestManifest');
$loader->autoload('TestNamespace\TestInvalidManifest');
try {
$config->enableManifest('TestNamespace\TestInvalidManifest');
$this->fail('RuntimeException was expected but not thrown');
} catch (RuntimeException $re) {
}
$config->enableManifest('TestNamespace\TestManifest');
$configs = $clientConfig->basicloader->classes;
$this->assertEquals('TestNamespace\TestManifest', $configs->current());
try {
$config->disableManifest('TestNamespace\TestInvalidManifest');
$this->fail('RuntimeException was expected but not thrown');
} catch (RuntimeException $re) {
}
$config->disableManifest('TestNamespace\TestManifest');
$this->assertEmpty($configs->current(), 'No config setting will exists');
// cleanup
file_put_contents($ini, '');
}