Using Docker, how do you execute PHP composer commands?

413
March 19, 2017, at 12:25 PM

I'm new to Docker and got my PHP environment set up with this as my Dockerfile:

FROM php:7.0-apache
COPY src/ /var/www/html/

Now I want to use PHP code I found on github and it says to install it I simply have to do:

composer require league/oauth2-client

Upon getting a shell into my docker container composer isn't even installed. How do I add composer into the Dockerfile and then execute the composer commands I need?

Answer 1

Upon getting a shell into my docker container

That would be at runtime (docker run)

Instead, create a new Dockerfile, which starts with FROM myimage (the php image you created), and add / copy what is missing.

See for instance "Get composer (php dependency manager) to run on a docker image build" as a possible approach.

READ ALSO
Return last 3 digits of a string seperately

Return last 3 digits of a string seperately

So let's say I have the following string:

405
“A server timeout has occurred” error connecting Dreamweaver to MySQL

“A server timeout has occurred” error connecting Dreamweaver to MySQL

I am trying to connect my website to MySQL on localhost under WAMPWhenever I enter my details in the MySQL connection tab and click "databases", it crashes and gives me the error:

370
PHP Function two loops from two tables

PHP Function two loops from two tables

I've got 2 tables one holds questions and one holds answersI was wondering if I can grab and echo them through a function

299
MySQL/PHP UPDATE query not working

MySQL/PHP UPDATE query not working

I looked up for an answer in many places (including here) before asking this question, but I'm desperately enough to ask

406