Presets for Laravel applications with Docker, PHPCS, PHPUnit, and etc.
jasonmccallister/laravel-preset is a Laravel package for presets for laravel applications with docker, phpcs, phpunit, and etc..
It currently has 1 GitHub stars and 120 downloads on Packagist (latest version v1.0.2).
Install it with composer require jasonmccallister/laravel-preset.
Discover more Laravel packages by jasonmccallister
or browse all Laravel packages to compare alternatives.
Last updated
This preset will install and prompt you to install Laravel official packages like Horizon and Telescope. This also includes a Makefile for helpful commands for local development and continous integration.
The overall goal is to make it as easy as possible to ship a project with Laravel using Docker, CI/CD, and PHPUnit testing.
Taking years of experience shipping PHP applications (both Craft CMS and Laravel) with Docker, this is a combination of lessons learned in one package.
You can install the package via composer:
composer require --dev jasonmccallister/laravel-preset
php artisan preset jasonmccallister
Follow the prompts on which database to use and what packages to include in the project.
Now all that is left is to run the following command:
make up
Running the preset command (php artisan preset jasonmccallister) will prompt you on the type of database you are going to use on the project. This will setup the Dockerfile and docker-compose file with the correct database dependencies.
There is a .dockerignore that will exclude the vendor and node_modules from the Docker Build Context. This is included to improve the build times for Docker.
The goal is to use the same Dockerfile for local development, CI/CD, and deploying a production image. By default only "production" OS packages are installed.
PHP Extensions like xdebug can be installed but are not enabled by default, there is a
Makefilecommand for that!
To make development with Docker easier locally, we use the docker-compose.yaml to scaffold the creation of the database, queue, and redis instance. Docker Compose makes it really easy to spin all of your services up with one command.
There are a few things of note with this file:
:cache to improve Docker's performance with macOS specifically but has no impact on other operating systemsThe preset will prompt you to install some recommended first-party packages.
Note: if you select to install Horizon, the preset will also prompt you to use the horizon command instead of
queue:work. Again this is optional but recommended when using Horizon.
The preset will also install a Makefile with a lot of helpful commands. Here is a list of available commands:
make build will build an imagemake composer will install composer dependencies inside of a throw away docker container and copy to your local machinemake down will stop, or shutdown, the projects servicesmake horizon will run php artisan horizon:installmake logs will show all of your serivces logs with the --follow flagmake migrate will run php artisan migrate inside of the docker containermake migrate:fresh will run pap artisan migrate inside of the docker containermake phpcs will apply .php_cs fixes on the app directorymake phpunit runs phpunit inside of the container, useful for CI/CD environmentsmake reports runs phpunit with HTML code coverage inside the containermake scale will scale your queue container up to 15 containers. Useful for testing concurrency of background jobs and queues locallymake seed runs db:seed inside of your containermake ssh will "ssh" you into the app container with a bash shellmake ssh-queue the same as the ssh command but will give you a bash shell in the queue containermake tag will tag your docker imagemake tinker runs php artisan tinker inside the app containermake telescope will run php artisan telescope:installmake testdox runs phpunit with the --testdox flag for prettier outputmake up is used to start all of your servicesmake xdebug will install the xdebug PHP Extension inside of your app containerIf you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.