services(); $baseDirectoryDependency = dirname(__FILE__).'/../src/Dependency/'; $directoriesDenpendencyInjection = scandir($baseDirectoryDependency); $dependencies = []; foreach($directoriesDenpendencyInjection as $directory) { if($directory != '.' && $directory != '..' && is_dir($baseDirectoryDependency.$directory)) { $filesDenpendencyInjection = scandir($baseDirectoryDependency.$directory); foreach($filesDenpendencyInjection as $file) { if($file != '.' && $file != '..') { $classDependency = 'App\Dependency\\'.$directory.'\\'.str_replace('.php', '', $file) ; $dependencies[] = new $classDependency; } } } } foreach($dependencies as $dependency) { $aliases = $dependency->getAliases(); foreach($aliases as $alias => $final) { $services->alias($alias, $final); } } };