Add classmap
to composer.json
.
"autoload": {
"classmap": ["folder1/", "folder2/"]
},
Then run composer.phar dumpautoload
to create composer/autoload_classmap.php
.
Change your code. After
require VENDOR_PATH . '/autoload.php';
Add
$class_map = require VENDOR_PATH . '/composer/autoload_classmap.php';
$new_class_map = array();
foreach ($class_map as $class => $file)
$new_class_map [strtolower($class)] = $file;
unset($class_map);
spl_autoload_register(function ($class)use($new_class_map)
{
$class = strtolower($class);
if (isset($new_class_map[$class]))
{
require_once $new_class_map[$class];
return true;
}
else
return false;
}, true, false);
unset($new_class_map);
This is the simplest way I have found.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…