INtelligent Dev: Adding Laradock it to your Workflow
I have been using Laradock as part of my development workflow for about three months now. I had used Valet for over a year and was mostly happy with it until I started having issues with the MariaDb database I installed via HomeBrew (as recommended by the documentation). After having MariaDB go down for the third time in six months and not being able to recover any of the databases again, I decided it was time to move on. I didn’t want to go back to using Homestead either. Vagrant seems so two thousand and late. I wanted to try tech that was a little more cutting edge.
I had attended a conference in Dallas a couple of years ago that had a session on Docker. I saw that it had potential back then, but the learning curve scared me off. I understood the general concept of Docker; I just could not get it to run and do what I wanted it to do. But when I came across Laradock and saw how simple it seemed to set up I thought I would give it a go. The setup is pretty straightforward. You just check out the Laradock repo in a ‘laradock’ folder in the root of an existing Laravel app. Here is the quick start ripped right from the Laradock documentation:
Let’s see how easy it is to install
1 – Clone Laradock inside your PHP project:
git clone https://github.com/Laradock/laradock.git
2 – Enter the laradock folder and rename
cp env-example .env
3 – Run your containers:
docker-compose up -d nginx mysql phpmyadmin redis workspace
4 – Open your Laravel project’s
.env file and set the following:
5 – Open your browser and visit localhost:
That's it! enjoy :)
You can easily customize the settings in the Laradock .env file too. For instance, if you want MySql to run on a port other than 3306, just update the ‘MYSQL_PORT’ setting.
The only real downside that I encountered is that I often switch between a few different Laravel applications that I am developing or maintaining throughout the day. That means that I have to bring one site down by running
docker-compose down to stop the current site running before switching over to the new site and running
docker-compose up -d nginx mysql phpmyadmin redis workspace to start up the new site. But I find that to be a fairly minor annoyance. Overall, I have found Laradock to be stable and really easy to work with once I understood a little more clearly how Docker works. Give it a try, and let me know what you think.
If you want a slightly more advanced tutorial on getting Laradock set up, check out Jared Law’s nice blog post.