public function __construct($config) { $this->startingTime = microtime(true); // Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/' define('PATH_SEP', DIRECTORY_SEPARATOR); $config['path_trunk'] = rtrim($config['path_trunk'], PATH_SEP) . PATH_SEP; if (!array_key_exists('path_trunk', $config)) { throw new Exception("path_trunk config not defined!"); } if (!is_dir($config['path_trunk'] . 'gulliver')) { throw new Exception(sprintf("Gulliver Framework not found in path trunk: '%s'", $config['path_trunk'])); } define('PATH_TRUNK', $config['path_trunk']); // Including these files we get the PM paths and definitions (that should be just one file. require_once PATH_TRUNK . 'gulliver/core/Autoloader.php'; $this->autoloader = Autoloader::getInstance(); }
/** * Constructor */ public function __construct() { if (ee()->config->item('github_addon_installer_disabled')) { show_error(lang('unauthorized_access')); } $this->base = BASE.AMP.'C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=github_addon_installer'; // no autoloader if (version_compare(APP_VER, '2.9', '<')) { require_once PATH_THIRD.'github_addon_installer/src/Application.php'; require_once PATH_THIRD.'github_addon_installer/src/Api.php'; require_once PATH_THIRD.'github_addon_installer/src/Repo.php'; require_once PATH_THIRD.'github_addon_installer/src/Installer/Installer.php'; require_once PATH_THIRD.'github_addon_installer/src/Installer/AbstractZipInstaller.php'; require_once PATH_THIRD.'github_addon_installer/src/Installer/FileInstaller.php'; require_once PATH_THIRD.'github_addon_installer/src/Installer/SystemUnzipInstaller.php'; require_once PATH_THIRD.'github_addon_installer/src/Installer/ZipArchiveInstaller.php'; } else { if ( ! class_exists('Autoloader')) { require_once APPPATH.'../EllisLab/ExpressionEngine/Core/Autoloader.php'; } Autoloader::getInstance()->addPrefix('eecli\\GithubAddonInstaller', PATH_THIRD.'github_addon_installer/src/'); } $temp_path = APPPATH.'cache/github_addon_installer/'; if (! is_dir($temp_path)) { mkdir($temp_path); } $this->application = new Application(PATH_THIRD, PATH_THIRD_THEMES, $temp_path); $this->manifest = $this->application->getManifest(); }
{ $path = 'app/' . $this->application . '/view/' . $mvpath . '.tpl'; if (file_exists($path)) { $layout = TplSimple::getInstance(); $layout->addBlock($block, $path, $data); return; } throw new Exception('Не найден файл шаблона: "' . $path . '"', 905); } public function language($mlpath) { $path = 'app/' . $this->application . '/language/' . $this->language->get() . '/' . $mlpath . '.php'; if (file_exists($path)) { $_ = []; require_once $path; $this->language->load($_); return; } throw new Exception('Не найден языковой файл : "' . $path . '"', 906); } public function __get($key) { return $this->registry[$key]; } public function __set($key, $value) { $this->registry[$key] = $value; } } Autoloader::getInstance();
* ------------------------------------------------------ * Define a custom error handler so we can log PHP errors * ------------------------------------------------------ */ set_error_handler('_exception_handler'); if (!is_php('5.3')) { @set_magic_quotes_runtime(0); // Kill magic quotes } /* * ------------------------------------------------------ * Load the autoloader and register it * ------------------------------------------------------ */ require APPPATH . '../EllisLab/ExpressionEngine/Core/Autoloader.php'; Autoloader::getInstance()->register(); /* * ------------------------------------------------------ * Set the subclass_prefix * ------------------------------------------------------ * * Normally the "subclass_prefix" is set in the config file. * The subclass prefix allows CI to know if a core class is * being extended via a library in the local application * "libraries" folder. Since CI allows config items to be * overriden via data set in the main index. php file, * before proceeding we need to know if a subclass_prefix * override exists. If so, we will set this value now, * before any classes are loaded * Note: Since the config file data is cached it doesn't * hurt to load it here.
/** * @group ZF-7473 */ public function testAutoloaderShouldReceiveNamespaceWithTrailingUnderscore() { $this->loader = new ResourceAutoloader(array('prefix' => 'FooBar', 'basePath' => realpath(__DIR__ . '/_files/ResourceAutoloader'))); $al = Autoloader::getInstance(); $loaders = $al->getPrefixAutoloaders('FooBar'); $this->assertTrue(empty($loaders)); $loaders = $al->getPrefixAutoloaders('FooBar_'); $this->assertFalse(empty($loaders)); $loader = array_shift($loaders); $this->assertSame($this->loader, $loader); }
<?php /* *********************************************************************************************** * * Phoebius Framework * * ********************************************************************************************** * * Copyright (c) 2009 phoebius.org * * All rights reserved. * ************************************************************************************************/ // // host config // define('APP_SLOT_CONFIGURATION', SLOT_PRESET_DEVELOPMENT); Autoloader::getInstance()->clearCache(); DBPool::add('default', PgSqlDB::create()->setDBName('phoebius-site')->setEncoding('utf8')->setUser('phoebus')->setPassword('')->setHost(''));
define('SLOT_CONFIGURATION_SEVERITY_VERBOSE', 0x10); define('SLOT_CONFIGURATION_SEVERITY_OPTIMIZE', 0x20); define('SLOT_PRESET_DEVELOPMENT', SLOT_CONFIGURATION_FLAG_DEVELOPMENT | SLOT_CONFIGURATION_SEVERITY_VERBOSE); define('SLOT_PRESET_TEST', SLOT_CONFIGURATION_FLAG_TEST | SLOT_CONFIGURATION_SEVERITY_VERBOSE | SLOT_CONFIGURATION_SEVERITY_OPTIMIZE); define('SLOT_PRESET_PRODUCTION', SLOT_CONFIGURATION_FLAG_PRODUCTION | SLOT_CONFIGURATION_SEVERITY_OPTIMIZE); if (!defined('APP_SLOT')) { define('APP_SLOT', isset($_ENV['PHOEBIUS_APP_SLOT']) ? $_ENV['PHOEBIUS_APP_SLOT'] : (isset($_SERVER['PHOEBIUS_APP_SLOT']) ? $_SERVER['PHOEBIUS_APP_SLOT'] : 'default')); } /** * Should be appended with a dot */ define('PHOEBIUS_TYPE_EXTENSION', '.class.php'); ////////////////////////////////////////////////////////////////////////////////////////////////// // no comment set_magic_quotes_runtime(0); // Set GMT timezone for compatibility (if you forgot to do that later) if (!isset($_ENV['TZ'])) { date_default_timezone_set('Europe/London'); } ////////////////////////////////////////////////////////////////////////////////////////////////// // FIXME: wrap the linear inclusion of core files with the code that caches all those files // inside separate file, that possibly can be used both by Autoloader $classes = array('IAutoloader' => 'Core/Bootstrap', 'StaticClass' => 'Core/Patterns', 'LazySingleton' => 'Core/Patterns', 'Assert' => 'Core', 'InternalSegmentCache' => 'Core/Bootstrap', 'IClassResolver' => 'Core/Bootstrap', 'ClassResolver' => 'Core/Bootstrap', 'CSharpStyleClassResolver' => 'Core/Bootstrap', 'PathResolver' => 'Core/Bootstrap', 'Autoloader' => 'Core/Bootstrap', 'Exceptionizer' => 'Core/Bootstrap', 'IErrorExceptionFactory' => 'Core/Bootstrap', 'ApplicationException' => 'Core/Exceptions', 'ArgumentException' => 'Core/Exceptions', 'ApplicationException' => 'Core/Exceptions', 'ExecutionContextException' => 'Core/Exceptions', 'InternalOperationException' => 'Core/Exceptions', 'RecoverableErrorFactory' => 'Core/Bootstrap', 'CompilationContextException' => 'Core/Exceptions', 'TypeUtils' => 'Utils'); foreach ($classes as $classname => $classDirectory) { require PHOEBIUS_BASE_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $classDirectory . DIRECTORY_SEPARATOR . $classname . PHOEBIUS_TYPE_EXTENSION; } ////////////////////////////////////////////////////////////////////////////////////////////////// Exceptionizer::getInstance()->register(E_ALL | E_STRICT, false, 'InternalOperationException')->setException(E_USER_ERROR, 'CompilationContextException')->setException(E_RECOVERABLE_ERROR, 'RecoverableErrorFactory'); set_include_path(PHOEBIUS_BASE_ROOT . '/lib' . PATH_SEPARATOR . get_include_path()); Autoloader::getInstance()->addResolver(CSharpStyleClassResolver::create()->setExtension(PHOEBIUS_TYPE_EXTENSION))->register();
public static function run(array $config) { if (version_compare(PHP_VERSION, self::REQUIRED_PHP_VERSION) < 0) { exit(sprintf('Uno requires PHP version %s or greater.', self::REQUIRED_PHP_VERSION)); } // setup autoloader Autoloader::getInstance(); // load uno default config file Config::factory($config); // include application bootstrap file if present $bootstrap = APPPATH . 'bootstrap.php'; if (is_file($bootstrap)) { include_once $bootstrap; } // set application timezone date_default_timezone_set(Config::getConfig()->get('timezone', 'Asia/Tokyo')); // set application charset mb_internal_encoding(Config::getConfig()->get('charset', 'UTF-8')); // dispatch request static::dispatcher()->dispatch(); }
/** * Constructor * * @param array|Zend_Config $options Configuration options for resource autoloader * @return void */ public function __construct($options) { if ($options instanceof \Zend_Config) { $options = $options->toArray(); } if (!is_array($options)) { throw new InvalidArgumentException('Options must be passed to resource loader constructor'); } $this->setOptions($options); $namespace = $this->getNamespace(); $prefix = $this->getPrefix(); if ((null === $namespace || null === $this->getBasePath()) && (null === $prefix || null === $this->getBasePath())) { throw new InvalidArgumentException('Resource loader requires both a base path and either a namespace or prefix for initialization'); } if (null !== $namespace) { Autoloader::getInstance()->unshiftAutoloader($this, $namespace); } elseif (null !== $prefix) { if (!empty($prefix)) { $prefix .= '_'; } Autoloader::getInstance()->unshiftAutoloader($this, $prefix, true); } }
// Copyright (c) 2015 Niels Sonnich Poulsen (http://nielssp.dk) // Licensed under the MIT license. // See the LICENSE file or http://opensource.org/licenses/MIT for more information. namespace Jivoo; if (defined('Jivoo\\VERSION')) { return; } /** * @var string Jivoo framework version string. */ const VERSION = '0.24.3'; /** * @var string Absolute path to Jivoo source directory. */ define('Jivoo\\PATH', str_replace('\\', '/', dirname(__FILE__))); require PATH . '/Autoloader.php'; if (version_compare(phpversion(), '5.3.0') < 0) { echo 'The Jivoo web application framework does not support PHP ' . phpversion() . '. PHP 5.3.0 or above is required.'; exit(1); } Autoloader::getInstance()->register(); Autoloader::getInstance()->addPath('Jivoo\\', PATH); if (!interface_exists('Psr\\Log\\LoggerInterface')) { require PATH . '/psrlog.php'; } require PATH . '/functions.php'; require PATH . '/exceptions.php'; require PATH . '/psrcache.php'; error_reporting(-1); Core\Log\ErrorHandler::getInstance()->register();
<?php // +------------------------------------------------------------ // | Mini Framework // +------------------------------------------------------------ // | Source: https://github.com/jasonweicn/MiniFramework // +------------------------------------------------------------ // | Author: Jason.wei <*****@*****.**> // +------------------------------------------------------------ if (!defined('MINI_PATH')) { define('MINI_PATH', dirname(__FILE__)); } if (!defined('APP_PATH')) { define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME'])); } if (!defined('SHOW_ERROR')) { define('SHOW_ERROR', false); } if (!defined('CACHE_PATH')) { define('CACHE_PATH', APP_PATH . DIRECTORY_SEPARATOR . 'cache'); } require MINI_PATH . DIRECTORY_SEPARATOR . 'Library' . DIRECTORY_SEPARATOR . 'Autoloader.php'; Autoloader::getInstance(MINI_PATH); //一切由此开始 App::getInstance()->run();
public function testSingleton() { $instance = Autoloader::getInstance(); $this->assertSame($instance, Autoloader::getInstance()); }
/** * Constructor */ public function __construct() { $this->initialize(); Autoloader::getInstance()->addPrefix('Michelf', APPPATH . 'libraries/typography/Markdown/Michelf/'); }
<?php Autoloader::getInstance()->addDir(dirname(__FILE__) . '/library/');
<?php /** * @package Dumpmon Scraper * @copyright 2015 Davide Tampellini - FabbricaBinaria * @license GNU GPL version 3 or later */ namespace Dumpmon; use Dumpmon\Utils\Clioptions; error_reporting(E_ALL); ini_set('display_errors', 1); require_once __DIR__ . '/autoloader.php'; \Autoloader::getInstance()->addMap('Dumpmon\\', __DIR__ . '/Dumpmon'); $banner = <<<BANNER Dump Scraper - Plain password importer Copyright (C) 2015 FabbricaBinaria - Davide Tampellini =============================================================================== Dump Scraper is Free Software, distributed under the terms of the GNU General Public License version 3 or, at your option, any later version. This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the license. See http://www.gnu.org/licenses/gpl-3.0.html for details. =============================================================================== BANNER; echo "\n" . $banner . "\n"; if (!file_exists(__DIR__ . '/settings.json')) { echo "\nPlease rename the file settings-dist.json to settings.json and fill the required info\n"; die; } $def_options = array('s:' => 'since:', 'u:' => 'until:', 'h' => 'help', 'f:' => 'file:'); $cli_options = getopt(implode(array_keys($def_options)), array_values($def_options));