Setting up a New Laravel Application and phpMyAdmin using Docker

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] in this video we're just going to walk through the setup of a new laravel application except this time using docker i do find that when working with composer and either the php artisan serve or using a local server like zamp or mamp you run into lots of issues with just the environment not being perfect the wrong version of php the wrong version of something and it doesn't quite work so we're going to walk through a more consistent version of installing laravel using docker we're going to assume you already have docker and things like composer already installed but once you have those things installed you can copy this command and this is going to set up a new laravel scaffolding and i'm just going to give this a different name we'll call it fresh laravel and the first time you run this it does take a while so we'll have to wait a minute here all right and then i just need to enter the password that i log in with and we are up and running so let's take a look at what files we have so if i cd into my fresh laravel folder and do a list you can see that i have all the typical files that come with a basic layer vault installation i'm going to jump over to my ide here and do the same thing so open up my fresh laravel folder and same thing all the typical laravel files now one thing that you may not have noticed before is we have this docker compose file and what this file does is it defines the server environment using docker that laravel needs to be deployed to now with typically with docker you would just go into that file and go type in docker compose up and it would take that and get it up and running however there is a slightly different version of docker called sale which just has a couple extra tools in in it to help us with our laravel application so if i go into that same folder and execute sale up it's going to get my laravel environment up and running and again this is going to take quite a long time the first time this runs through and if we take a look at our docker desktop application now we now have a new group of containers called fresh layerville and you can see we have all the requirements we need to run our layer valve application and if we open up a new tab and go to localhost you can see we have our new laravel application now the one thing that this doesn't provide is the ability to manage the database now typically you could manage the database through migration files and seeding files but we'll get there for now let's just add a phpmyadmin container to our application so i'm going to go back to our command here i'm going to cancel and shut that down and if i go into my dockercompose.yml and just take a couple notes here so first of all my database service is called mysql it's a part of the sale network and those are the two pieces i need to make to get php up and running so i'm going to add a new service to my app and that service i'm just going to call phpmyadmin and the image that i'm going to use is the phpmyadmin image and a couple things i need to add here first of all it depends and i typically put this one first on are mysql up and running all right so we want our maya skills container up and running before we initialize our php myadmin we want to set some environment variables and the environment variables are are where is our php where is our mysql host and the host can just reference the container by name and the port and i believe the port that this runs off is our default port 3306 and finally we also need to add it to the same network as our database which is the sale network and to launch if we want to view phpmyadmin we're going to use a port we just need to use any port that's not in use so we'll use 8001 so 8001 in our local environment is going to redirect to our phpmyadmin container port 80. and we can save that go back to our terminal and run sale up oh and i just have a typo in here i spell environment wrong and we'll try that again all right no errors this time again this might take a while the first time and if i go back to my browser and refresh this page should still work but now if i go to port 8001 it's going to redirect to my php my admin container and if i look at my database settings so if i scroll up to my mysql image the database root password and host and so on are all being pulled from these environment variables so if i want to look these up i can open up my env file the default username here is sale and password is password and now if i go in here and type the username sale and the password password i can log in and there is my database so currently it's empty i need to start working on migration and seating files to get some content into there all right so to get my migration up and running i can go back to my docker application open up my application and here i want to open up my laravel container so i'm going to open up the command line and if i do a list you can see i am currently in my laravel folder so from here i can go php artisan migrate refresh okay and that ran without any errors so i can close that and if i go back to phpmyadmin and just refresh you can see my data is all ready to go [Music] [Music] you
Info
Channel: Adam Thomas
Views: 70,718
Rating: undefined out of 5
Keywords:
Id: AGg8UJoQGWk
Channel Id: undefined
Length: 9min 11sec (551 seconds)
Published: Tue Mar 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.