Last active
February 18, 2024 12:05
-
-
Save andyshinn/e2c428f2cd234b718239 to your computer and use it in GitHub Desktop.
Docker Compose PHP Composer Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"mfacenet/hello-world": "v1.*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app: | |
restart: 'yes' | |
image: php:7 | |
command: php -S 0.0.0.0:8000 /app/index.php | |
ports: | |
- "8000:8000" | |
volumes: | |
- .:/app | |
composer: | |
restart: 'no' | |
image: composer/composer:php7 | |
command: install | |
volumes: | |
- .:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use HelloWorld\SayHello; | |
echo SayHello::world(); |
Restart policy of 'yes' is not valid (at least now) docker restart policies.
Also, I had to use docker-compose up
to install the container.
And...it appears that the remote repository no longer exists.
[tyler.christian@ThisOne my-dir]$ git clone git@github.com:mfacenet/hello-world.git
Cloning into 'hello-world'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Thanks!
It just works (TM)
Thanks, worked for me!
@andyshinn How does it work with PHP 7.2?
Is there some error with PHP 7.2? I don't use PHP daily so I am not sure what the difference might be.
Perfect! thanks for share!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys,
Thanks for the gist
Can you advice how it's better to use composer container when you application need to run composer inside it's own container?
For example, if you use symfony/phpunit-bridge to run tests, it try to install required packages.