From 1815262258cebba040b6e1132f15ec3fc03caac8 Mon Sep 17 00:00:00 2001 From: jsavell Date: Fri, 7 Oct 2016 16:36:45 -0500 Subject: [PATCH] Further Composer adjustments --- Core/Lib/autoload.php | 27 +-------------------------- Core/Lib/functions.php | 18 ++++++++++++++++++ composer.json | 2 +- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Core/Lib/autoload.php b/Core/Lib/autoload.php index a702e79..515a549 100644 --- a/Core/Lib/autoload.php +++ b/Core/Lib/autoload.php @@ -2,35 +2,10 @@ namespace Core\Lib; use Core\Classes as CoreClasses; -/* -* This autoloader will search NAMESPACE_APP for a matching file containing the declaration of that class or interface. -*/ -spl_autoload_register(function($class) { - loadFile($class,NAMESPACE_APP,PATH_APP); -}); -echo 'test'; -/* +/** * This autoloader will search NAMESPACE_CORE for a matching file containing the declaration of that class or interface. */ - spl_autoload_register(function($class) { loadFile($class,NAMESPACE_CORE,PATH_CORE); }); -function loadFile($class,$nameSpace,$baseDirectory) { - $len = strlen($nameSpace); - if (strncmp($nameSpace, $class, $len) == 0) { - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = $baseDirectory.nameSpaceToPath($class).'.php'; - // if the file exists, require it - if (file_exists($file)) { - require $file; - } - } -} - -function nameSpaceToPath($nameSpace) { - return str_replace('\\', '/', $nameSpace); -} \ No newline at end of file diff --git a/Core/Lib/functions.php b/Core/Lib/functions.php index c9d2dcc..74700c2 100644 --- a/Core/Lib/functions.php +++ b/Core/Lib/functions.php @@ -16,4 +16,22 @@ function getLogger() { } return $GLOBALS['logger']; } + +function loadFile($class,$nameSpace,$baseDirectory) { + $len = strlen($nameSpace); + if (strncmp($nameSpace, $class, $len) == 0) { + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = $baseDirectory.nameSpaceToPath($class).'.php'; + // if the file exists, require it + if (file_exists($file)) { + require $file; + } + } +} + +function nameSpaceToPath($nameSpace) { + return str_replace('\\', '/', $nameSpace); +} ?> \ No newline at end of file diff --git a/composer.json b/composer.json index 8fb4290..531ea2f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload": { "psr-4": { - "Core\\": "Pipit/" + "Core\\": "/tamu-lib/pipit/Core" } } } \ No newline at end of file