Skip to content

Commit

Permalink
Added standalone autoload for non-composer users
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolim4 committed May 2, 2016
1 parent fde02ea commit 5825b52
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/autoload.php
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);
}

0 comments on commit 5825b52

Please sign in to comment.