Skip to content

Commit

Permalink
Update examples to current versions
Browse files Browse the repository at this point in the history
  • Loading branch information
J0WI committed Dec 2, 2019
1 parent 20bb4f5 commit 81ba3a1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions php/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -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%%

Expand All @@ -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" ]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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
```

Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 81ba3a1

Please sign in to comment.