php-7.2,7.2,alpine,latestDockerfilephp-7.3Dockerfilephp-5.6Dockerfilephp-7.2-stretch,stretch,debianDockerfilephp-7.3-stretchDockerfilephp-5.6-stretchDockerfilephp-7.2-apache,apacheDockerfilephp-7.3-apacheDockerfilephp-5.6-apacheDockerfile
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
This is a Dockerised Solution for running Composer.
$ docker pull willhallonline/composer
$ docker pull willhallonline/composer:stretch
$ docker pull willhallonline/composer:apache
$ docker run -it --rm -v $(pwd):/app willhallonline/composer --version
Composer version 1.7.2 2018-08-16 16:57:12
$ docker run --rm -it -v $(pwd):/app willhallonline/composer:alpine composer require guzzlehttp/guzzle
Using version ^6.3 for guzzlehttp/guzzle
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
- Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)
- Installing guzzlehttp/guzzle (6.3.3): Downloading (100%)
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Writing lock file
Generating autoload files
Will create:
composer.json
composer.lock
vendor/ # vendor packages installed here
Providing you already have composer.json (and maybe composer.lock)
docker run --rm -it -v $(pwd):/app willhallonline/composer:alpine composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 4 installs, 0 updates, 0 removals
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)
- Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
- Installing guzzlehttp/guzzle (6.3.3): Downloading (100%)
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Generating autoload files
Note that this will install files as root user. You can potentially add the -u 1000:1000 options to the command, however, this may introduce other challenges.
- Will Hall, contact me on https://www.willhallonline.co.uk.