If you have all of your classes inside one directory, you could just hard code it relative to the current script and that would eliminate the need for a reflection class. For example, if the current script is in /var/www/foo
and the classes are in /var/www/classes
, just do:
$include_file_name = glob(__DIR__ . '/../classes' . '*.inc');
However if the classes can come from multiple directories, using a reflector like that seems pretty appropriate to me, however you could also add $fdir
into the glob()
string instead of doing chdir()
like this, but of course that's just micro-optimization:
$include_file_name = glob($fdir ."/*.inc");