本文整理汇总了PHP中Autoload::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Autoload::init方法的具体用法?PHP Autoload::init怎么用?PHP Autoload::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autoload
的用法示例。
在下文中一共展示了Autoload::init方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
if (!self::$app) {
$config = Autoload::load('App\\config');
self::$app = new self($config);
Autoload::init();
$modules = self::app()->getConfig('Modules');
foreach ($modules as $item) {
$module = 'Modules/' . $item;
Autoload::load($module, 1);
}
Session::init();
Router::init();
}
}
示例2: dirname
#!/usr/bin/php
<?php
include dirname(__DIR__) . '/framework/init.php';
Autoload::init(array(LIBS, EXTERNAL, FRAMEWORK_LIBS, FRAMEWORK_EXTERNAL), CACHE);
Config::parse('define.ini', true);
Cache::$base_prefix = Config::get('cache', 'prefix');
function clear_dir($dir)
{
if (!file_exists($dir)) {
return;
}
foreach (glob($dir . '/*') as $file) {
unlink($file);
}
}
$file = array_shift($argv);
$set = array_shift($argv);
if (empty($set)) {
die('Set needed' . "\n");
}
$set = Database::get_full_row('set', 'id = ?', $set);
if (empty($set)) {
die('Incorrect set' . "\n");
}
if (!$set['grabbed']) {
Grabber::get_set($set['id']);
}
$folder = IMAGES . SL . 'import';
if (!file_exists($folder . SL . $set['id']) || !is_dir($folder . SL . $set['id'])) {
die('No import folder' . "\n");
}
示例3: self
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Registrar.
*
* @return void
*/
public function register()
{
spl_autoload_register(function ($name) {
// fix root
if ($name[0] != '\\') {
$name = '\\' . $name;
}
// only couch files
if (1 !== strpos($name, __NAMESPACE__)) {
return;
}
// prepare file name & path
$name = substr($name, 1 + strlen(__NAMESPACE__));
$file = sprintf('%s/%s.php', __DIR__, str_replace('\\', '/', $name));
require $file;
});
}
}
// auto-init for including
return Autoload::init();
示例4: catch
<?php
require_once 'engine/utils.php';
require_once 'engine/autoload.php';
Autoload::init('config/autoload.php');
use App\Config, App\Request, App\User, App\Route, App\View, App\Timer, App\Debug, App\Mysql, App\Response;
try {
Config::load('config/settings.php');
Config::applyHostSettings('config/hosts.php');
Mysql::setHost(Config::get('dbConnection'));
Timer::start();
User::startSession();
Request::parse();
Route::add(['/dumper' => 'dumper', '/module' => 'module', '/login' => 'login', '/tasks' => 'page', '/profile' => 'page', '/projects' => 'page', '/workspace' => 'page', '/404' => 'error', '/' => 'page']);
Route::go();
Timer::showExecutionTime();
Mysql::showResources();
Response::out();
} catch (\Exception $e) {
Debug::showException($e);
}
示例5: Router
<?php
// Require Loader
if (file_exists("app/libraries/Autoload.php")) {
require_once "app/libraries/Autoload.php";
}
// Initialize all requires classes
Autoload::init();
// To avoid triggering a PHP notice, we can't use array elements that do not exists
if (!isset($_GET['url'])) {
$_GET['url'] = '/';
}
$router = new Router($_GET['url']);
$router->setDefaultController('HomeController');
$router->setDefaultAction('index');
$router->parse();
$controller = $router->getController();
$action = $router->getAction();
$arguments = $router->getArguments();
$controllerClass = Controller::factory($controller);
$actionName = $action;
// This is the key part, we call a method that has a name stored in $stored
$controllerClass->{$actionName}($arguments);
示例6: search_lib
include_once $library;
return true;
}
return false;
}
protected static function search_lib($name)
{
foreach (self::$directories as $directory) {
if (file_exists($directory . SL . $name)) {
return $directory . SL . $name;
}
}
return false;
}
}
Autoload::init(array(ROOT_DIR . SL . 'libs', ENGINE . SL . 'external'));
function autoload_old($class_name)
{
$class = ROOT_DIR . SL . 'libs' . SL . str_replace('__', SL, $class_name) . '.php';
if (file_exists($class)) {
include_once $class;
return true;
}
$class = ROOT_DIR . SL . 'engine' . SL . str_replace('__', SL, $class_name) . '.php';
if (file_exists($class)) {
include_once $class;
return true;
}
if (!preg_match('/^Read_/i', $class_name) && !preg_match('/^Api_/i', $class_name)) {
if (_TYPE_ == 'index') {
include_once TEMPLATE_DIR . SL . '404' . SL . 'fatal.php';
示例7:
<?php
/// logic unrelated to a specific request
/** @file */
#Tool, used by config
require_once $_ENV['systemFolder'] . 'tool/Tool.php';
#used by autoloader
require_once $_ENV['systemFolder'] . 'tool/Arrays.php';
require_once $_ENV['systemFolder'] . 'tool/Hook.php';
require_once $_ENV['systemFolder'] . 'tool/CommonTraits.php';
#Config setting
require_once $_ENV['systemFolder'] . 'tool/Config.php';
Config::init();
#Autoloader
require_once $_ENV['systemFolder'] . 'tool/Autoload.php';
$autoload = Autoload::init(null, $_ENV['autoloadIncludes']);
spl_autoload_register(array($autoload, 'auto'));
#composer autload
if (is_file($_ENV['composerFolder'] . 'autoload.php')) {
require_once $_ENV['composerFolder'] . 'autoload.php';
}
set_error_handler($_ENV['errorHandler'], $_ENV['errorsHandled']);
set_exception_handler($_ENV['exceptionHandler']);
Config::loadUserFiles($_ENV['preRoute']);
#pre session request handling; for file serving and such.
require_once $_ENV['systemFolder'] . 'tool/control/Route.php';
\control\Route::handle($_SERVER['REQUEST_URI']);