Laravel Change default routing behaviour in Laravel 5.2.31 +


  • public function map(Router $router) // Define the routes for the application.
  • protected function mapWebRoutes(Router $router) // Define the "web" routes for the application.


Router $router\Illuminate\Routing\Router $router


Middleware means that every call to a route will go through the middleware before actually hitting your route specific code. In Laravel the web middleware is used to ensure session handling or the csrf token check for example.

There are other middlewares like auth or api by default. You can also easily create your own middleware.