Laravel-modules: How to list routes for specific module?

Created on 8 Sep 2018  路  4Comments  路  Source: nWidart/laravel-modules

Hello,
Thank you for this package. I'm trying to dump the routes for modules in separate JSON files. How can I list routes for modules and dump them to JSON?

Most helpful comment

php artisan route:list | grep 'Modules\\Blog'

All 4 comments

php artisan route:list | grep 'Modules\\Blog'

Thank you for your response.
How can same thing be achieved in application via browser?

function getModuleRoutes($moduleName, $baseModulesPath = 'Modules')
{
    return collect(Route::getRoutes())->filter(function ($item) use ($baseModulesPath, $moduleName) {
        return isset($item->action['namespace']) && starts_with($item->action['namespace'], "{$baseModulesPath}\\{$moduleName}");
    })->values()->all();
}

Route::get('/test', function () {
    return getModuleRoutes('Blog');
});

Great! Thank you that helped

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djoudi picture djoudi  路  4Comments

dang-tien picture dang-tien  路  3Comments

NexxusPlexx picture NexxusPlexx  路  4Comments

invaders-xx picture invaders-xx  路  3Comments

ghost picture ghost  路  4Comments