I use the Slim framework, and I wish I could properly handle self loading files. At the moment I have this:
spl_autoload_register(function($class){
$list = array(
dirname(__DIR__).'/app/'.$class.'.php',
dirname(__DIR__).'/lib/'.$class.'.php',
dirname(__DIR__).'/lib/'.$class.'.class.php',
);
foreach($list as $k => $v){if(file_exists($v)){
include $v; return true;
}}
});
And this structure:
lib\
Function.php
MyNamespace\
Class.php
vendor\
slim\
web\
.htaccess
index.php
Is it the best method to autoload Slim without using Composer? (in the case you can't install Composer on your server or you don't want to)