From 20bb4f5561f952b4d153d9b84ed1363a941d8104 Mon Sep 17 00:00:00 2001 From: J0WI Date: Sun, 8 Sep 2019 17:24:34 +0200 Subject: [PATCH 1/3] Document default extensions --- php/content.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/php/content.md b/php/content.md index 7f6f79415..a25d0e423 100644 --- a/php/content.md +++ b/php/content.md @@ -49,7 +49,7 @@ RUN docker-php-source extract \ ### PHP Core Extensions -For example, if you want to have a PHP-FPM image with `iconv` and `gd` extensions, you can inherit the base image that you like, and write your own `Dockerfile` like this: +For example, if you want to have a PHP-FPM image with `gd` extensions, you can inherit the base image that you like, and write your own `Dockerfile` like this: ```dockerfile FROM %%IMAGE%%:7.2-fpm @@ -57,7 +57,6 @@ RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ - && docker-php-ext-install -j$(nproc) iconv \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd ``` @@ -66,6 +65,10 @@ Remember, you must install dependencies for your extensions manually. If an exte See ["Dockerizing Compiled Software"](https://tianon.xyz/post/2017/12/26/dockerize-compiled-software.html) for a description of the technique Tianon uses for determining the necessary build-time dependencies for any bit of software (which applies directly to compiling PHP extensions). +### Default extensions + +Some extensions are compiled by default. This depends on the PHP version you are using. Run `php -m` in the container to get a list for your specific version. + ### PECL extensions Some extensions are not provided with the PHP source, but are instead available through [PECL](https://pecl.php.net/). To install a PECL extension, use `pecl install` to download and compile it, then use `docker-php-ext-enable` to enable it: From 81ba3a1e7eaf49956e53480c7a7b42195fa835e0 Mon Sep 17 00:00:00 2001 From: J0WI Date: Mon, 2 Dec 2019 22:05:50 +0100 Subject: [PATCH 2/3] Update examples to current versions --- php/content.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/php/content.md b/php/content.md index a25d0e423..ecb3306a5 100644 --- a/php/content.md +++ b/php/content.md @@ -2,7 +2,7 @@ PHP is a server-side scripting language designed for web development, but which can also be used as a general-purpose programming language. PHP can be added to straight HTML or it can be used with a variety of templating engines and web frameworks. PHP code is usually processed by an interpreter, which is either implemented as a native module on the web-server or as a common gateway interface (CGI). -> [wikipedia.org/wiki/PHP](http://en.wikipedia.org/wiki/PHP) +> [wikipedia.org/wiki/PHP](https://en.wikipedia.org/wiki/PHP) %%LOGO%% @@ -11,7 +11,7 @@ PHP is a server-side scripting language designed for web development, but which ### Create a `Dockerfile` in your PHP project ```dockerfile -FROM %%IMAGE%%:7.2-cli +FROM %%IMAGE%%:7.4-cli COPY . /usr/src/myapp WORKDIR /usr/src/myapp CMD [ "php", "./your-script.php" ] @@ -29,7 +29,7 @@ $ docker run -it --rm --name my-running-app my-php-app For many simple, single file projects, you may find it inconvenient to write a complete `Dockerfile`. In such cases, you can run a PHP script by using the PHP Docker image directly: ```console -$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:7.2-cli php your-script.php +$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:7.4-cli php your-script.php ``` ## How to install more PHP extensions @@ -41,7 +41,7 @@ We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-instal In order to keep the images smaller, PHP's source is kept in a compressed tar file. To facilitate linking of PHP's source with any extension, we also provide the helper script `docker-php-source` to easily extract the tar or delete the extracted source. Note: if you do use `docker-php-source` to extract the source, be sure to delete it in the same layer of the docker image. ```Dockerfile -FROM %%IMAGE%%:7.2-cli +FROM %%IMAGE%%:7.4-cli RUN docker-php-source extract \ # do important things \ && docker-php-source delete @@ -52,7 +52,7 @@ RUN docker-php-source extract \ For example, if you want to have a PHP-FPM image with `gd` extensions, you can inherit the base image that you like, and write your own `Dockerfile` like this: ```dockerfile -FROM %%IMAGE%%:7.2-fpm +FROM %%IMAGE%%:7.4-fpm RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ @@ -74,9 +74,9 @@ Some extensions are compiled by default. This depends on the PHP version you are Some extensions are not provided with the PHP source, but are instead available through [PECL](https://pecl.php.net/). To install a PECL extension, use `pecl install` to download and compile it, then use `docker-php-ext-enable` to enable it: ```dockerfile -FROM %%IMAGE%%:7.2-cli -RUN pecl install redis-4.0.1 \ - && pecl install xdebug-2.6.0 \ +FROM %%IMAGE%%:7.4-cli +RUN pecl install redis-5.1.1 \ + && pecl install xdebug-2.8.1 \ && docker-php-ext-enable redis xdebug ``` @@ -89,11 +89,11 @@ RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \ It is *strongly* recommended that users use an explicit version number in their `pecl install` invocations to ensure proper PHP version compatibility (PECL does not check the PHP version compatiblity when choosing a version of the extension to install, but does when trying to install it). -For example, `memcached-2.2.0` has no PHP version constraints (https://pecl.php.net/package/memcached/2.2.0), but `memcached-3.0.4` requires PHP 7.0.0 or newer (https://pecl.php.net/package/memcached/3.0.4). When doing `pecl install memcached` (no specific version) on PHP 5.6, PECL will try to install the latest release and fail. +For example, `memcached-2.2.0` has no PHP version constraints (https://pecl.php.net/package/memcached/2.2.0), but `memcached-3.1.4` requires PHP 7.0.0 or newer (https://pecl.php.net/package/memcached/3.1.4). When doing `pecl install memcached` (no specific version) on PHP 5.6, PECL will try to install the latest release and fail. Beyond the compatibility issue, it's also a good practice to ensure you know when your dependencies receive updates and can control those updates directly. -Unlike PHP core extensions, PECL extensions should be installed in series to fail properly if something went wrong. Otherwise errors are just skipped by PECL. For example, `pecl install memcached-2.2.0 && pecl install redis-2.2.8` instead of `pecl install memcached-2.2.0 redis-2.2.8`. However, `docker-php-ext-enable memcached redis` is fine to be all in one command. +Unlike PHP core extensions, PECL extensions should be installed in series to fail properly if something went wrong. Otherwise errors are just skipped by PECL. For example, `pecl install memcached-3.1.4 && pecl install redis-5.1.1` instead of `pecl install memcached-3.1.4 redis-5.1.1`. However, `docker-php-ext-enable memcached redis` is fine to be all in one command. ### Other extensions @@ -162,7 +162,7 @@ The default config can be customized by copying configuration files into the `$P ### Example ```dockerfile -FROM %%IMAGE%%:7.2-fpm-alpine +FROM %%IMAGE%%:7.4-fpm-alpine # Use the default production configuration RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" From b5ae66754b1eb7a5448ba22b7b7d4800700de809 Mon Sep 17 00:00:00 2001 From: J0WI Date: Tue, 3 Dec 2019 11:41:18 +0100 Subject: [PATCH 3/3] Fix gd config for 7.4 --- php/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/content.md b/php/content.md index ecb3306a5..d8a18f96e 100644 --- a/php/content.md +++ b/php/content.md @@ -57,7 +57,7 @@ RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ - && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) gd ```