本文整理汇总了PHP中Composer\Autoload\ClassLoader::unregister方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::unregister方法的具体用法?PHP ClassLoader::unregister怎么用?PHP ClassLoader::unregister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Autoload\ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::unregister方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
public function __destruct()
{
if ($this->loader) {
$this->loader->unregister();
$this->loader = NULL;
}
}
示例2: runCommand
/**
* Runa a command in and returns the commandTester object. This method can
* run either a blend command or a sub-application command
* @param string $projectFolder
* @param string $commandName
* @param string $params
* @param string $app In case of null it will be set to blend. In case of
* className as string, the application's class name will be used
* @return CommandTester
*/
public static function runCommand($projectFolder, $commandName, array $params = [], $app = null, $runOptions = [])
{
$loader = new ClassLoader();
$curDir = getcwd();
chdir($projectFolder);
if ($app === null) {
$app = new SetupApplication($projectFolder);
} else {
if (is_string($app)) {
$classes = explode('\\', $app);
$loader->addPsr4("{$classes[0]}\\", $projectFolder . '/src/');
$loader->register(true);
$c = new Container();
$c->defineSingletonWithInterface('app', $app, ['scriptPath' => $projectFolder . '/bin']);
$app = $c->get('app');
}
}
$commandTester = new CommandTester($app->find($commandName));
$commandTester->execute($params, $runOptions);
chdir($curDir);
$c = null;
if ($loader) {
$loader->unregister();
}
return $commandTester;
}
示例3: build
/**
* Builds internal request handling objects.
*
* @return $this
*/
public function build()
{
if ($this->cache) {
$loader = new ClassLoader();
if ($this->apc) {
$apcLoader = new ApcClassLoader(sha1('ReactServer'), $loader);
$loader->unregister();
$apcLoader->register(true);
}
}
require_once $this->root_dir . '/AppKernel.php';
define('KERNEL_ROOT', $this->root_dir);
$kernel = new ReactKernel($this->env, $this->env === 'dev' ? true : false);
$this->loop = Factory::create();
// TODO make config for this part
if (class_exists('\\Doctrine\\DBAL\\Driver\\PingableConnection')) {
$this->loop->addPeriodicTimer(15, function () use($kernel) {
foreach ($kernel->getContainer()->get('doctrine')->getConnections() as $connection) {
if ($connection instanceof \Doctrine\DBAL\Driver\PingableConnection) {
$connection->ping();
}
}
});
}
$this->socket = new SocketServer($this->loop);
$http = new HttpServer($this->socket, $this->loop);
$http->on('request', $this->handleRequest($kernel));
return $this;
}
示例4: activate
static function activate(ClassLoader $loader)
{
self::$loader = $loader;
self::$loader->unregister();
self::$activated = [__CLASS__ => __CLASS__];
self::$included = [__CLASS__ => __CLASS__];
self::$error_reporting = error_reporting();
// Регистрация метода-обработчика автозагрузки классов
spl_autoload_register(['\\boolive\\core\\Core', 'loadClass'], true, true);
// Регистрация метода-обработчка завершения выполнения системы
register_shutdown_function(['\\boolive\\core\\Core', 'deactivate']);
// Регистрация обработчика исключений
set_exception_handler(['\\boolive\\core\\Core', 'exception']);
// Регистрация обработчика ошибок
set_error_handler(['\\boolive\\core\\Core', 'error']);
// Временая зона
date_default_timezone_set('UTC');
// Настройка кодировки
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
mb_http_output('UTF-8');
// При необходимости, каждый класс может автоматически подключиться и активироваться, обработав событие Core::activate.
\boolive\core\events\Events::trigger('Core::activate');
}
示例5: testFindFile
/**
* @covers ::findFile
*/
public function testFindFile()
{
$finder = new ClassFinder();
// The full path is returned therefore only tests with
// assertStringEndsWith() so the test is portable.
$this->assertStringEndsWith('core/tests/Drupal/Tests/UnitTestCase.php', $finder->findFile(UnitTestCase::class));
$class = 'Not\\A\\Class';
$this->assertNull($finder->findFile($class));
// Register an autoloader that can find this class.
$loader = new ClassLoader();
$loader->addClassMap([$class => __FILE__]);
$loader->register();
$this->assertEquals(__FILE__, $finder->findFile($class));
// This shouldn't prevent us from finding the original file.
$this->assertStringEndsWith('core/tests/Drupal/Tests/UnitTestCase.php', $finder->findFile(UnitTestCase::class));
// Clean up the additional autoloader after the test.
$loader->unregister();
}
示例6: build
/**
* Builds internal request handling objects.
*
* @return $this
*/
public function build()
{
if ($this->cache) {
$loader = new ClassLoader();
if ($this->apc) {
$apcLoader = new ApcClassLoader(sha1('ReactServer'), $loader);
$loader->unregister();
$apcLoader->register(true);
}
}
require_once $this->root_dir . '/AppKernel.php';
define('KERNEL_ROOT', $this->root_dir);
$kernel = new ReactKernel($this->env, $this->env === 'dev' ? true : false);
$this->loop = Factory::create();
$this->socket = new SocketServer($this->loop);
$http = new HttpServer($this->socket, $this->loop);
$http->on('request', $this->handleRequest($kernel));
return $this;
}
示例7: run
public static function run(ClassLoader $autoloader)
{
// Converts warnings to exceptions
ErrorHandler::register();
$config = self::loadConfig();
if (isset($config['extension_autoloader']) && $config['extension_autoloader']) {
$autoloadFile = $config['extension_autoloader'];
if (!file_exists($autoloadFile)) {
throw new \InvalidArgumentException(sprintf('Could not find extension autoload file "%s"', $autoloadFile));
}
$autoloader->unregister();
include $autoloadFile;
$autoloader->register(true);
}
$extensions = $config['extensions'];
$extensions[] = 'PhpBench\\Extension\\CoreExtension';
unset($config['extensions']);
$container = new Container($extensions, $config);
$container->init();
$container->get('console.application')->run();
}
示例8: register
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
$this->composerClassLoader->unregister();
spl_autoload_register(array($this, 'loadClassWithAlias'), true, $prepend);
}
示例9: initializeSettings
/**
* Locate site path and initialize settings singleton.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* In case the host name in the request is not trusted.
*/
protected function initializeSettings(Request $request)
{
$site_path = static::findSitePath($request);
$this->setSitePath($site_path);
$class_loader_class = get_class($this->classLoader);
Settings::initialize($this->root, $site_path, $this->classLoader);
// Initialize our list of trusted HTTP Host headers to protect against
// header attacks.
$host_patterns = Settings::get('trusted_host_patterns', array());
if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
throw new BadRequestHttpException('The provided host name is not valid for this server.');
}
}
// If the class loader is still the same, possibly upgrade to the APC class
// loader.
if ($class_loader_class == get_class($this->classLoader) && Settings::get('class_loader_auto_detect', TRUE) && function_exists('apcu_fetch')) {
$prefix = Settings::getApcuPrefix('class_loader', $this->root);
$apc_loader = new ApcClassLoader($prefix, $this->classLoader);
$this->classLoader->unregister();
$apc_loader->register();
$this->classLoader = $apc_loader;
}
}
示例10: __construct
/**
* @param ComposerClassLoader $composerClassLoader
*/
public function __construct(ComposerClassLoader $composerClassLoader)
{
$composerClassLoader->unregister();
$this->composerClassLoader = $composerClassLoader;
}
示例11: reloadClassLoader
/**
* Reloac class loader
*/
protected function reloadClassLoader()
{
$this->classLoader->unregister();
$this->classLoader = $this->generateClassLoader($this->getComposer());
$this->classLoader->register();
}
示例12: unRegisterLoader
private function unRegisterLoader()
{
$this->loader->unregister();
}