Laravel Sail Tutorial - First Party Laravel Docker Development Environment

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone laravel sale was recently released which is a really great package that is basically a command line interface for getting laravel development environment up and running using docker this does not require a much of prior docker experience and you can be up and running in no time with php mysql and redis and maybe in future it will contain more things this package in my opinion is very useful for both experienced developers with docker or for developers who have very little to no docker experience laravel sale is very customizable it uses docker compose file so you're able to customize it to your own liking it is supported on mac os linux and windows via wso2 i do have prior docker experience and have been using custom docker setup for my own projects but i think for new projects i'm going to be using laravel sale and customize it to my needs let's follow the instructions and get it working together so as per the instructions laravel sale is automatically installed with all the new laravel applications you would need to follow the installation documentation to get the laravel up and running before you play around with the sale you could also get sale installed on existing applications i might make a separate video about it but i don't think it's that complicated so let's open installation documentation and follow the steps there as you may have noticed the laravel documentation has been updated and you just need to follow the getting started section for your os i am on windows currently so i'm going to be following the windows guide so we click on that and the requirement for this to work on windows you need to have docker desktop setup and you should also make sure that you have wsl2 installed and enabled if you don't know how to install or enable these the links for them are in the documentation and i'm also going to leave them in the description it's actually pretty simple to get this installed i'm going to show you what it should look like once it's installed so i'm going to open the settings of docker desktop and within the general tab you need to check the use the wso2 based engine and then once that's checked you switch to the resources and wsl integration and here you need to make sure that you actually have the distribution installed and if you do it just toggle that on i'm going to include these links in the description so if you don't have it installed or if you don't know how to install docker then please follow the instructions on those links so since i have the docker installed the next step is to run this in the terminal we actually need to launch the terminal from our distribution in my case that's ubuntu and i'm going to run that command here and this is going to take a minute or two all right so it has finished installing laravel and now we're ready to use laravel cell so let's open the code in the editor i'm going to open phpstorm and in the php storm we see that docker compose file so this is the file that the larval sale will use to launch your containers so we can close this out and let's go back to the documentation and now we're ready to run sale up before doing that i'm going to create an alias so that i can just do sale up without referencing the vendor directory so i'm going to open the terminal and put that in there and now i'm going to cd into the directory and run sale up and i'm going to run it in the background and this will take a while for the first time but then after that it will be faster alright so after it has downloaded all the images and started the docker containers we can open docker desktop and we see the example up running here and this has four containers right here now let's go to the localhost and we see that laravel is running with the latest laravel version and latest php version so that was pretty quick now let's go over the docker compose file and see what we can customize as you notice by default the mysql is running on port 3306 the application itself is running on the port 80. if you have multiple laravel applications where you want to run at the same time then you will need to update the ports because if you run another application on port 80 they will conflict so in that case you will need to change the port and that can happen within your docker compose file so if you don't have experience with the docker compose or docker itself i suggest you watch some tutorials on docker itself before trying to customize something in the laravel sale otherwise if you don't have experience you don't need to actually customize anything as you noticed i just installed it and laravel is up and running and i can just get to work this is the up port and by default it's set to 80. so you could define this in your emv file to a different port and then it will be running on that port then we have mysql also running on the default 3306 port and same goes for redis there is redis port and you could enable the memcache container if you want to use memcached and it also has mail hub which is useful to test your emails and this runs on the port 80 25 so if we open localhost port 80 25 we see that mail hog is running here now you could also execute commands in the container so for example you would think that you could just do php artisan tinker and you would think that this would work and you won't because php is not installed on the distribution it is installed within the docker container so you have to run it through the docker container there are two ways you can do this one way is you could ssh into the docker container itself and that can be done by doing docker exec it and pass the name of the container which is example app laravel test and then bash and then you could run the php artisan tinker and all the artisan commands within here the other and easier way is that larval actually has a command called sail which basically just proxies all the commands through that docker container so sail artisan tinker and this will proxy the command through the container you could also do cell php-v and get the php version or run any php scripts if you want to so you don't actually have to go inside your container and run these commands from there and here are other commands that you could run you could run npm commands you could run composer commands and so on also laravel cell has currently two php versions one is php8 and the other one is php 7.4 and to change the php version you just need to update in your docker compose file right here so you would just update this to 7.4 also as mentioned before if you want to have some additional containers you could just modify this docker compose file and add your containers as you need and if you actually want to customize even more including the docker file then you could just publish its files by using cell artisan cell publish and this will publish the docker file and it will also update your docker compose so instead of it referencing to the vendor it will now reference your local docker folder and if you notice it created a docker folder here and if we open that we have these two php versions and within here we have the php ini we have the start container script we have the supervisor configuration and the docker file so you could edit pretty much anything here and but as mentioned before if you're not experienced with docker i would suggest to just leave it with defaults or watch few tutorials on how to use docker and docker compose and you could customize it to your liking so this is it for this video thank you so much for watching if you're interested in more of my tutorials i'm currently working on learn php the right way course so definitely check it out if you're interested in learning php from the beginner's level all the way to advanced also please give this video a thumbs up share and subscribe and i will see you on the next video
Info
Channel: Program With Gio
Views: 53,478
Rating: undefined out of 5
Keywords: laravel, laravel sail, laravel docker, laravel dev environment, laravel development, laravel development environment, laravel with docker, laravel docker-compose, laravel + docker, laravel & docker, laravel and docker
Id: 4K4nkncZ2OQ
Channel Id: undefined
Length: 7min 32sec (452 seconds)
Published: Thu Dec 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.