Skip to content

Instantly share code, notes, and snippets.

@foxted
Created October 30, 2015 04:41
Show Gist options
  • Save foxted/065bd6e23d83b8b4dd48 to your computer and use it in GitHub Desktop.
Save foxted/065bd6e23d83b8b4dd48 to your computer and use it in GitHub Desktop.
Read routes from any PHP file in app/Http/Routes folder.
<?php
namespace NW\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'NW\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
$routeFiles = $this->app['files']->files(app_path('Http/Routes'));
foreach($routeFiles as $routeFile)
require $routeFile;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment