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


PHP Loader\StandardAutoloader类代码示例

本文整理汇总了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();
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:38,代码来源:CLIWCF.class.php

示例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');
     }
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:26,代码来源:TarTest.php

示例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());
         }
     }
 }
开发者ID:rzak,项目名称:ModSync,代码行数:25,代码来源:Autoloader.php

示例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');
开发者ID:khusamov,项目名称:leading,代码行数:9,代码来源:bootstrap.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();
开发者ID:prolic,项目名称:SxMail,代码行数:30,代码来源:Bootstrap.php

示例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)) {
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:31,代码来源:pluginmap_generator.php

示例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));
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:7,代码来源:StandardAutoloaderTest.php

示例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);
 }
开发者ID:rexmac,项目名称:zf2,代码行数:9,代码来源:StandardAutoloaderTest.php

示例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;
 }
开发者ID:negativespace,项目名称:phrozn,代码行数:27,代码来源:Autoloader.php

示例10: registerAddtionalNamespace

 /**
  * @param StandardAutoloader &$loader
  * @return StandardAutoloader $loader
  */
 protected static function registerAddtionalNamespace(StandardAutoloader &$loader) : StandardAutoloader
 {
     $loader->registerNamespace('Gz3Base\\Test', __DIR__);
     return $loader;
 }
开发者ID:geolysis,项目名称:gz3-base,代码行数:9,代码来源:TestInitialiser.php

示例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;
开发者ID:Luyanda86,项目名称:silex-playground,代码行数:31,代码来源:bootstrap+-+Copy.php

示例12: registerEntityFilesNamespace

 /**
  * @param string $namespace
  * @param string $namespaceDirectory
  */
 protected function registerEntityFilesNamespace($namespace, $namespaceDirectory)
 {
     $loader = new StandardAutoloader();
     $loader->registerNamespace($namespace, $namespaceDirectory);
     $loader->register();
 }
开发者ID:slawojstanislawski,项目名称:doctrine-entity-creator,代码行数:10,代码来源:SchemaService.php

示例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')));
开发者ID:Theodia,项目名称:theodia.org,代码行数:20,代码来源:Bootstrap.php

示例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');
开发者ID:skpd,项目名称:bootstrap,代码行数:31,代码来源:_init.php

示例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, '');
    }
开发者ID:ruflin,项目名称:zf2,代码行数:70,代码来源:ConfigTest.php


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