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
Makefile
command 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:
- The volumes are tagged with
:cache
to improve Docker's performance with macOS specifically but has no impact on other operating systems - There are lines commented out if you are not using Laravel Passport
- No image is specified for the app and queue containers, this will default to the root folders name. Instead the file will look at the Dockerfile and build the image if it cannot find it locally
The 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 runphp artisan horizon:install
make logs
will show all of your serivces logs with the--follow
flagmake migrate
will runphp artisan migrate
inside of the docker containermake migrate:fresh
will runpap artisan migrate
inside of the docker containermake phpcs
will apply.php_cs
fixes on theapp
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
runsdb:seed
inside of your containermake ssh
will "ssh" you into the app container with a bash shellmake ssh-queue
the same as thessh
command but will give you a bash shell in the queue containermake tag
will tag your docker imagemake tinker
runsphp artisan tinker
inside the app containermake telescope
will runphp artisan telescope:install
make 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 container
If you discover any security related issues, please email themccallister@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.