freekmurze / freek-dev-comments

2 stars 0 forks source link

1976-develop-faster-by-adding-dev-routes-file-in-a-laravel-app #82

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Develop faster by adding dev routes file in a Laravel app - Freek Van der Herten's blog on PHP, Laravel and JavaScript

https://freek.dev/1976-develop-faster-by-adding-dev-routes-file-in-a-laravel-app

PhillipMwaniki commented 3 years ago

Is there a way you can restrict the routes from running on prod or having a security key popup on them? I see them as a security risk if left unchecked.

chygoz2 commented 3 years ago

@PhillipMwaniki I think that the environment check in the RouteServiceProvider before the dev routes are mapped takes care of your concern.

PanjiNamjaElf commented 3 years ago

How if we can check it also if file exist load the dev.php route if not dont load it so it will not commited on version control 🙄

nhtahoe commented 3 years ago

Adding the following to the boot() method in RouteServiceProvider (Laravel 8.41.0) worked for me:

if (app()->environment('local')) {
    Route::middleware('web')
        ->namespace($this->namespace)
        ->group(base_path('routes/dev.php'));
}
PhillipMwaniki commented 3 years ago

Adding the following to the boot() method in RouteServiceProvider (Laravel 8.41.0) worked for me:

if (app()->environment('local')) {
    Route::middleware('web')
        ->namespace($this->namespace)
        ->group(base_path('routes/dev.php'));
}

Thanks a lot. I do appreciate it.