diff --git a/src/autoload.php b/src/autoload.php index ed9b710b..01a254aa 100644 --- a/src/autoload.php +++ b/src/autoload.php @@ -12,13 +12,10 @@ * ---------------------------------------------------------------------------- */ function register($namespace, $path) { - spl_autoload_register(function ($class) { + spl_autoload_register(function ($class) use ($namespace, $path) { // project-specific namespace prefix $prefix = 'EA\\' . $namespace . '\\'; - // base directory for the namespace prefix - $base_dir = __DIR__ . '/' . $path; - // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { @@ -32,7 +29,7 @@ function register($namespace, $path) { // replace the namespace prefix with the base directory, replace namespace // separators with directory separators in the relative class name, append // with .php - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; + $file = $path . '/' . str_replace('\\', '/', $relative_class) . '.php'; // if the file exists, require it if (file_exists($file)) {