Creating a fresh Laravel installation with Docker

Tag
Published:
Author: Ally

Why? Simply, because I like Docker to do these things, and because I have lots of urges to start a project but never complete it.

But really, why?

I like to leave the root directory for things, such as bespoke README for the entire project, and maybe other files, such as bash scripts, other infrastructure config, terraform scripts, etc. This has the bonus that it doesn’t clutter up the Laravel ‘workspace’ and that src folder can have its own README for more bespoke details about the application itself rather than the entire project.


Just 3 easy steps:

docker run \
  --rm \
  --tty \
  --interactive \
  --user=$(id -u) \
  --volume="$(pwd):/app" \
  --volume="${COMPOSER_HOME:-$HOME/.composer}:/tmp" \
  composer:2.0 create-project laravel/laravel src

Could also add --env COMPOSER_AUTH='{"github-oauth": {"github.com": ""}}' if you require it.

This composer image comes with PHP 8 - if that’s a problem, I’ve used thecodingmachine/php:7.4-v3-cli and friends in the past to accomplish the same thing.


Bonus aside: I finally got around to making a helper to make a blog post.

make article

MySQL query logging on Mac
Using Xdebug with Laravel Valet
To bottom
To top
< SM
max-width: 640px