-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added standalone autoload for non-composer users
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* | ||
* This file is part of phpFastCache. | ||
* | ||
* @license MIT License (MIT) | ||
* | ||
* For full copyright and license information, please see the docs/CREDITS.txt file. | ||
* | ||
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com | ||
* @author Georges.L (Geolim4) <[email protected]> | ||
* | ||
*/ | ||
|
||
define('PSSDB_PHP_EXT', 'php'); | ||
|
||
/** | ||
* Register Autoload | ||
*/ | ||
spl_autoload_register(function ($entity) { | ||
$module = explode('\\', $entity, 2); | ||
if ($module[ 0 ] !== 'phpssdb') { | ||
/** | ||
* Not a part of phpssdb file | ||
* then we return here. | ||
*/ | ||
return; | ||
} | ||
|
||
$entity = str_replace('\\', '/', $entity); | ||
$path = __DIR__ . '/' . $entity . '.' . PSSDB_PHP_EXT; | ||
|
||
if (is_readable($path)) { | ||
require_once $path; | ||
} | ||
}); | ||
|
||
if (class_exists('Composer\Autoload\ClassLoader')) { | ||
trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpssdb" instead of hard-autoloading.', | ||
E_USER_WARNING); | ||
} |