TL; DR: require require_once, .
, , Illuminate\Foundation\Console\RouteCacheCommand.
, getFreshApplicationRoutes, .
, :
$app = require $this->laravel->bootstrapPath().'/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
$routesCnt = $app['router']->getRoutes()->count();
$this->info($routesCnt);
, .
, , Http\Routes, .
"require" "require_once".
!
.
, , - ( ).
.json:
"psr-4": {
"App\\": "app/"
}
, / . , , , .
, , *_once.
RouteServiceProvider.php, map, :
$router->group(['namespace' => $this->namespace], function ($router) {
foreach (new \DirectoryIterator(app_path('Http/Routes')) as $file)
{
$path = app_path('Http/Routes').DIRECTORY_SEPARATOR.$file->getFilename();
if ($file->isDot() || $file->isDir() || $file->getFilename() == '.gitignore')
continue;
require $path;
$included[] = $path;
}
});