Move routes into separate directory

This commit is contained in:
James Brooks
2014-11-16 23:00:37 +00:00
parent 3c416efa7e
commit a7dc7d7871
2 changed files with 19 additions and 14 deletions

View File

@@ -1,17 +1,17 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
routesInDirectory();
Route::get('/', function()
{
return View::make('hello');
});
function routesInDirectory($app = '') {
$routeDir = app_path('routes/' . $app . ($app !== '' ? '/' : NULL));
$iterator = new RecursiveDirectoryIterator($routeDir);
$iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
foreach ($iterator as $route) {
$isDotFile = strpos($route->getFilename(), '.') === 0;
if (!$isDotFile && !$route->isDir()) {
require $routeDir . $route->getFilename();
}
}
}

5
app/routes/app.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
Route::get('/', function() {
return View::make('hello');
});