Skip to content

Add support for Composer #17

Closed
Closed
@naneau

Description

@naneau

Composer is the de facto package manager for PHP. Nearly all (modern) libraries and frameworks rely on it. The current PHP images do not support it, because the openssl exension is missing. While Composer falls back to the git transport method (see second example below), this may not be available for all packages.

One-liner installation

The "recommended" install method, using a one-liner fails:

Dockerfile:

FROM php:5.5
RUN php -r "readfile('https://getcomposer.org/installer');" | php

Result:

Step 1 : RUN php -r "readfile('https://getcomposer.org/installer');" | php
 ---> Running in 21722cb03536

Warning: readfile(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1

Warning: readfile(https://getcomposer.org/installer): failed to open stream: No such file or directory in Command line code on line 1

Manual Installation

Adding it manually (download from https://getcomposer.org/composer.phar) works, but results in warnings. In this case installation proceeds, because git can be used to fetch the source, this may not work for all packages.

Dockerfile:

FROM php:5.5

# Create working dir
RUN mkdir /composer-test

# Manually add composer
ADD composer.phar /composer-test/composer.phar

# Try to install a package
WORKDIR /composer-test
RUN php composer.phar require monolog/monolog

Result:

Step 4 : RUN php composer.phar require monolog/monolog
 ---> Running in 58633ee9c005
Using version ~1.11 for monolog/monolog
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing psr/log (1.0.0)
Failed to download psr/log from dist: You must enable the openssl extension to download files via https
Now trying to download from source
  - Installing psr/log (1.0.0)
    Cloning fe0936ee26643249e916849d48e3a51d5f5e278b

  - Installing monolog/monolog (1.11.0)
Failed to download monolog/monolog from dist: You must enable the openssl extension to download files via https
Now trying to download from source
  - Installing monolog/monolog (1.11.0)
    Cloning ec3961874c43840e96da3a8a1ed20d8c73d7e5aa

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions