Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all routes, Laravel 4

What I want is just to use one controller at the moment which should handle every request that comes to my laravel 4 application. The problem is that none of the solutions on stackoverflow or elsewhere are working for me.

That's what i currently have:

Route::any('(.*)', function(){
  return View::make('hello');
});

Now when browsing to the page I get an error everytime saying:

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

Hope somebody could help me out!

like image 724
Andre Zimpel Avatar asked Apr 23 '13 20:04

Andre Zimpel


People also ask

What is the command to list all routes?

The route:list command can be used to show a list of all the registered routes for the application. This command will display the domain, method, URI, name, action and middleware for the routes it includes in the generated table.

How many types of routes are there in Laravel?

Route Parameters Laravel provides two ways of capturing the passed parameter: Required parameter. Optional Parameter.

Where is Laravel routing file?

The Default Route Files All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider . The routes/web.php file defines routes that are for your web interface.


2 Answers

Regular expressions are set as requirements and not directly in the route.

Route::any('{all}', function($uri)
{
    return View::make('hello');
})->where('all', '.*');
like image 188
Jason Lewis Avatar answered Nov 15 '22 20:11

Jason Lewis


Route::group(array('prefix' => '/', 'before' => 'MAKEYOUROWNFILTER'), function()
{

    // your routers after the / ....
});

// and in filters.php

Route::filter('MAKEYOUROWNFILTER', function()
{

    // do stuff or just
    return View::make('hello');

});
like image 37
mangas Avatar answered Nov 15 '22 19:11

mangas