mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 06:45:44 +01:00
Updated bootstrap with full composer and pear compatibility
This commit is contained in:
parent
57f8a8aad0
commit
dca743e94d
1 changed files with 23 additions and 7 deletions
|
|
@ -1,16 +1,32 @@
|
|||
<?php
|
||||
<?php /** a Courtesy of Respect/Foundation */
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
set_include_path('../library' . PATH_SEPARATOR . get_include_path());
|
||||
$paths = explode(PATH_SEPARATOR,get_include_path());
|
||||
$paths[] = trim(`pear config-get php_dir`);
|
||||
|
||||
/**
|
||||
* Autoloader that implements the PSR-0 spec for interoperability between
|
||||
* PHP software.
|
||||
*/
|
||||
// See if composer is present then it should be picked up too
|
||||
if (file_exists(dirname(__DIR__).'/vendor/composer')) {
|
||||
$map = require dirname(__DIR__).'/vendor/composer/autoload_namespaces.php';
|
||||
foreach ($map as $path)
|
||||
$paths[] = $path;
|
||||
}
|
||||
|
||||
natsort($paths);
|
||||
array_unshift($paths, dirname(__DIR__) .'/library');
|
||||
set_include_path(implode(PATH_SEPARATOR, array_unique($paths)));
|
||||
|
||||
/** Autoloader that implements the PSR-0 spec for interoperability between PHP software. */
|
||||
spl_autoload_register(
|
||||
function($className) {
|
||||
$fileParts = explode('\\', ltrim($className, '\\'));
|
||||
static $composerClassmap;
|
||||
if (!isset($composerClassmap) && file_exists(dirname(__DIR__).'/vendor/composer'))
|
||||
$composerClassmap = require dirname(__DIR__).'/vendor/composer/autoload_classmap.php';
|
||||
// Also consider composer classMap of course
|
||||
if (isset($composerClassmap[$className]))
|
||||
return require $composerClassmap[$className];
|
||||
|
||||
$fileParts = explode('\\', ltrim($className, '\\'));
|
||||
|
||||
if (false !== strpos(end($fileParts), '_'))
|
||||
array_splice($fileParts, -1, 1, explode('_', current($fileParts)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue