Laravel learning journey #2: How to do basic routing

Routing means when a person enters the URL of your website, be it http://localhost:8000/blog, http://localhost:8000/faq, how will Laravel handle what happens next, which page to show?

For Laravel 5.3, the documentation on routing is here.

By default, when you run php artisan serve for the first time, Laravel will show you the default Laravel page at http://localhost:8000.

Laravel 5.3 default welcome page

Laravel 5.3 default welcome page

The way Laravel works to show you this page is go to /routes/web.php.

You will see

The / means that when you are at the root url http://localhost:8000/, laravel will return view named welcome. Where is this view stored? Go to /resources/views/welcome.blade.php. Feel free to edit this file to whatever you want, like changing the background color.

So the web.php file in routes folder will match your url, and present the view located at resources/views folder.

The blade.php of the views file shows that Laravel is using Laravel blade templating system. It lets you insert variable from your routing/ controller to view, etc, which we will delve into later.

Leave a Reply