Laravel 5.8 – From The Ground Up
Lesson 2 of 52 · Laravel 5.8 Tutorial From Scratch – e02 – Web Routes · Education
Laravel 5.8 Tutorial From Scratch – e02 – Web Routes
so in the previous lesson we were able to get our basic laravel installation and we were able to run PHP artisan serf to see the website on our browser so we
are still running PHP artisan surf in the background and you're gonna have to keep this running in the background in order for you to be able to continue to see this page if we hit refresh then of
course it's still there now if I do control C and exit that process when I go back and I hit refresh nope it doesn't work anymore so just keep that in mind make sure that you are
constantly running PHP artisan surf and just leave it there now most terminals allow tabs so if you need your terminal just open a new tab and run any commands on there instead always keep that tab
with that PHP artisan surf so with that being said I'm gonna switch over to my editor I happen to use phpstorm but I've used sublime text I've used code I've used NetBeans code is a great free one
and I would probably start there unless you have a subscription to something like sublime or phpstorm I prefer phpstorm because it's actually an IDE and not
just a text editor however a lot of times I'll switch back to sublime text if I just need some quick edits on a project and I don't want to have to index it and do all of the things that
phpstorm does for a project so with that being said I have that project open right now so this is my first project which of course I created on episode 1 and the very first thing you're gonna
notice is that there are a lot of files and directories in here now here's the good news you don't have to worry about anything at all we're gonna take it one step at a time and eventually you will
know what all of these directories and files do but for now I just want you to worry about one particular file and that is located inside the directory called routes and inside of there there is a
web that PHP file let's go ahead and open that now so if you open that file you're gonna get something like this PHP storm automatically collapses comment so if I open it up this is probably more
like what you see so the first thing you're going to see here's that you can get a route with Slash and slash just simply means homepage and it's gonna return a view
called welcome and if I switch back to our browser I'll hit refresh and this is the page that we are seeing just to prove that I'm gonna go ahead and delete that altogether I'm gonna hit save
refresh now I just get a blank page so if instead I returned coders tape there we are so now we know how that very first page gets loaded I'm gonna undo this a couple of times and we're back to
what it ships with so route get slash function okay now let's say that we wanted to add another route let's add a new one and let's just say I want to call it contact now of course I will
show you how to make views later on but for now we're simply gonna return contact us okay if we go back to the browser we can now visit slash contact and there we are contact us so this
brings us to our very first lesson about laravel so there's web dot PHP file located inside the routes is where we're going to define all of the routes that your application will respond to now
there are other route files but for now we're just gonna worry about the web and web meaning routes that you want to visit through a browser so you can make as many of these as you want and this is
where you would declare them so let's make another one for about and let's return about us we go back to the browser we change from contact to about and now we are there about us so now we
have three pages we have the home page which is still the default we have contact and we have about and there we are so in the next lesson we're going to explore how to actually add some HTML
into these routes
Let’s take care of having our application respond to some URLs using the web routes file.
For the best experience, follow along in our interactive school at https://www.coderstape.com
Resources
Course Source Code
https://github.com/coderstape/laravel-58-from-scratch
Hit us up on Twitter with any questions or comments @codertape (https://twitter.com/CodersTape)
About This Course
Ready to get started on your path to Laravel Artisan? In this series, we are breaking down all of the basics of Laravel to get you comfortable using the world’s most popular PHP framework. Let’s get started!