-
-
Save augustohp/1561214 to your computer and use it in GitHub Desktop.
VorticePHP2 Loader
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
<?php | |
/** | |
* Simple loader class | |
* | |
* Usage: new Vortice\Common\Loader('Zend', './Zend'); | |
* @author Carlos André Ferrari <carlos@ferrari.eti.br> | |
*/ | |
namespace Vortice\Common; | |
class Loader | |
{ | |
/** | |
* Register a new namespace | |
* | |
* @var string | |
* @var string | |
* @var string | |
* @access public | |
*/ | |
public function __construct($namespace, $folder, $remove = '') | |
{ | |
spl_autoload_register( | |
function($classname) use ($folder, $namespace, $remove){ | |
if (false == strstr($classname, $namespace)) return; | |
$classname = str_replace($remove, '', $classname); | |
$file = str_replace('\\', DIRECTORY_SEPARATOR, $classname); | |
require_once $folder . $file . '.php'; | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment