How To Run A Laravel Project In The Browser | Learn Laravel From Scratch | Laravel For Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right then guys now that we have done most of the installation and stuff i would like to continue on with opening our application in the browser before we continue on if you like my content and you want to see more there's a red button down below which says subscribe so if you want to see more just click on it and otherwise enjoy the video now laravel comes with a pretty cool package called artisan and you basically can see artisan as the command line interface of laravel itself later on you will get a better understanding how artisan is and what you should do or could do with it you could create classes without even writing a single line of code in your code editor i assume that you guys have worked with php before where you basically could go into your local host and click on the right directory so let's do that so in our google chrome let's write down localhost hit enter and you can see that this site cannot be reached because localhost refused it well it's slightly different with a laravel project since it's not located inside our hd docs think about it what do we need in order to run php well with php we need to run xampp but for laravel we don't need xampp there's no connection between laravel and xampp now you're probably wondering well how do i even start it then besides creating classes and models in artisan there's also an option to open a project in the browser so let's go back to our terminal and right here we need to go inside the directory of the project that we would like to open so let's go to cd desktop and inside our desktop we want to cd into workspace and inside our workspace we want to cd into first project let's hit enter that's ls just to be clear that we're in the right directory all right and in here we basically need to write down php space artisan space and what we want to say to artisan is that we need to serve so basically to start running this project that we're in right now so let's hit enter and as you can see on our screen our laravel development server has started and you can see an http link right here so let's copy it you could also command click on it but then it will open in safari for me so let's hop back to chrome let's replace localhost with a pad that we just had and wow our first laravel project has been opened now if we hop back to our terminal you can see that it's not possible to do anything in the command line interface because it's serving at the moment so if you want to perform other stuff inside the command line you basically need to open a new tab so let's well click on the plus symbol right here and we have our new tab to stop it from serving we basically need to control z all right then you can see that our laravel project has been stopped let's hop back to google chrome refresh it and you can see that it won't stop refreshing because while we stop serving it you need to be aware that you can only use the php artisan serve inside the directory of a laravel project so let's get out of our first project by saying cd dot dot we're back in our workspace and right here let's write down php artisan surf and you can see that it's not possible to open php artisan let me zoom in a little bit the reason why this is happening is because the surf command is basically a shortcut for the php built-in web server which we'll call the main of our application which then will be run now another good thing to remember is that by default the http server will listen to port 8000 as you could see right here however there might be a case where your port number 8000 is in use and i can give you one example and this is something that happened to me before let's say that you're working with api connections later on and you have a java project running on port number 8000 next to your java project you want to run your laravel project what you basically need to do is to say php artisan server again but it won't work so we can change that we can give our own port to artisan we basically need to say php artisan surf space dash dash port is equal to whatever number you want so let's say 8081 hit enter well obviously we need to go into the right directory excuse me so let's say cd first project and let's hit the arrow up button still php artisan serve port is eight zero eight one let's hit enter and we're starting our larval project on port number 8081 let's copy it go back to chrome hit it inside the url and you can see that we're running it on 8081 and this works fine but what if you want to change it now let's go back to our root directory so let's write cd and in here we could basically say sudo nano forward slash etc forward slash hosts and these are the hosts that we have we could say 127.0.0.1 has a name of first project dot test and let's get rid of the localhost that we have so let's do that right control x save it say yes enter and let's do it one more time to see if it works all right let's copy first project test let's get out of it let's go back to google chrome let's write it inside our url let's hit enter and you can see that it works as well so instead of having the ip address and our port we could basically say firstproject.test
Info
Channel: Code With Dary
Views: 47,846
Rating: undefined out of 5
Keywords: laravel, laravel 8, laravel php framework tutorial - full course for beginners 2020, laravel 8 tutorial for beginners, laravel php framework tutorial full course for beginners, learn laravel for beginners, learn laravel step by step, laravel full course, php laravel youtube, how to learn laravel, laravel tutorial 2020 - the complete developer course, laravel tutorials from scratch to advanced, laravel from scratch - series introduction, run laravel in browser
Id: I-EJXY3n7aQ
Channel Id: undefined
Length: 6min 25sec (385 seconds)
Published: Fri Nov 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.