Laravel 5 Tutorial : Routing Basics in Laravel

Laravel 5 tutorial for beginners : how to basic routing in Laravel Artisan framework? Basic routing is meant to route your request to an appropriate controller.

Laravel 5 Tutorial - How to Routing in Laravel Artisan framework? in the Laravel PHP Framework we can make a route to an appropriate controller, So, the Basic of routing in Laravel meant how to route our request to a controller, the controller will send any request to the View. The routes of any application in laravel can be defined in app/Http/routes.php file.

Please read :
  1. How to Install Laravel 5 in your LocalHost
  2. Why you must use Laravel 5 for any apps?
Here is the general route syntax for each of the possible request :

Route::get('/', function () {
   return 'Hello World!';

Route::post('foo/bar', function () {
   return 'Hello World!';

Route::put('foo/bar', function () {

Route::delete('foo/bar', function () {

Routing Basic in Laravel

In Routes.php file app\Http\routes.php we can create new route.


// Call homeController using Index Method

Route::get('/', 'homeController@index');

So, at the Controller folder app/Http/controllers/ we can create a homeController.php



namespace AppHttpControllers;

use IlluminateHttpRequest;

use AppHttpRequests;

class homeController extends Controller
  // index functions have a view method that will read welcome.blade.php file in View folder
    public function index(){
      return view('welcome');

now, homeController.php have a view method that will read 'welcome.blade.php' file in Views folder resources\views , lets create welcome.blade.php file.


<!DOCTYPE html>

        <link href="" rel="stylesheet" type="text/css">

            html, body {
                height: 100%;

            body {
                margin: 0;
                padding: 0;
                width: 100%;
                display: table;
                font-weight: 100;
                font-family: 'Lato';

            .container {
                text-align: center;
                display: table-cell;
                vertical-align: middle;

            .content {
                text-align: center;
                display: inline-block;

            .title {
                font-size: 96px;
        <div class="container">
            <div class="content">
                <div class="title">Laravel 5</div>

Execute on your Browser :

Please execute the root url in your browser,  http://localhost:8080/ you will see the wellcome.blade.php that "Laravel 5" message.

How it work's?

  1. First, we will execute the root URL of the Laravel application is http://localhost:8080/.
  2. After executed the URL, our routes.php file will run the functions.In our case, it will match to get the method and the root ('/') URL. Then will read 'homeController.php' file that at the index function.
  3. at the 'homeController.php' we have the index function that will call the template file resources/views/welcome.blade.php. he function later calls the view() function with argument 'welcome' without using the blade.php. It will produce the following HTML output.

Some Routes Method in routes.php


// First Route method – Root URL will match this method
Route::get('/', function () {
   return view('welcome');

// Second Route method – Root URL with ID will match this method
   echo 'ID: '.$id;

// Third Route method – Root URL with or without name will match this method
Route::get('/user/{name?}',function($name = ''){
   echo "Name: ".$name;

Video tutorial Basic Routing in Laravel

See you next lessons ..
references :


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^

Follow by E-Mail


ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
KODE AJAIB: Laravel 5 Tutorial : Routing Basics in Laravel
Laravel 5 Tutorial : Routing Basics in Laravel
Laravel 5 tutorial for beginners : how to basic routing in Laravel Artisan framework? Basic routing is meant to route your request to an appropriate controller.
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy