Loading…

What is routing in Laravel 5 and how we can use it?

All routes in Laravel are defined in route files which are available in the routes directory. The routes/web.php file defines every route that is used for the web interface. These routes are assigned the all web middleware group, which gives features like CSRF protection and session state.

How we can use it?

Routes in Laravel 5 are located in routes directory and Laravel has basically 3 categories namely.

  • api.php
  • web.php
  • console.php

You can use php artisan route:list to check all available route lists. Examples are given below:-

Example

                                        

Route::get('/', function () {
    return view('welcomepage');
});

Suggest An Answer

No suggestions avaliable!

Latest post from Laravel 5 Interview Questions

Ask Question