Skip to content

Commit b3bf4f3

Browse files
authored
Merge pull request #2343 from infosiftr/php-bumps
Update mentioned php versions that are EOL
2 parents f184c45 + 1dfc91d commit b3bf4f3

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

php/content.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PHP is a server-side scripting language designed for web development, but which
1111
### Create a `Dockerfile` in your PHP project
1212

1313
```dockerfile
14-
FROM %%IMAGE%%:7.4-cli
14+
FROM %%IMAGE%%:8.2-cli
1515
COPY . /usr/src/myapp
1616
WORKDIR /usr/src/myapp
1717
CMD [ "php", "./your-script.php" ]
@@ -29,7 +29,7 @@ $ docker run -it --rm --name my-running-app my-php-app
2929
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:
3030

3131
```console
32-
$ 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
32+
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:8.2-cli php your-script.php
3333
```
3434

3535
## How to install more PHP extensions
@@ -41,7 +41,7 @@ We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-instal
4141
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.
4242

4343
```Dockerfile
44-
FROM %%IMAGE%%:7.4-cli
44+
FROM %%IMAGE%%:8.2-cli
4545
RUN docker-php-source extract \
4646
# do important things \
4747
&& docker-php-source delete
@@ -52,7 +52,7 @@ RUN docker-php-source extract \
5252
For example, if you want to have a PHP-FPM image with the `gd` extension, you can inherit the base image that you like, and write your own `Dockerfile` like this:
5353

5454
```dockerfile
55-
FROM %%IMAGE%%:7.4-fpm
55+
FROM %%IMAGE%%:8.2-fpm
5656
RUN apt-get update && apt-get install -y \
5757
libfreetype-dev \
5858
libjpeg62-turbo-dev \
@@ -76,59 +76,57 @@ Some extensions are compiled by default. This depends on the PHP version you are
7676
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:
7777

7878
```dockerfile
79-
FROM %%IMAGE%%:7.4-cli
80-
RUN pecl install redis-5.1.1 \
81-
&& pecl install xdebug-2.8.1 \
79+
FROM %%IMAGE%%:8.2-cli
80+
RUN pecl install redis-5.3.7 \
81+
&& pecl install xdebug-3.2.1 \
8282
&& docker-php-ext-enable redis xdebug
8383
```
8484

8585
```dockerfile
86-
FROM %%IMAGE%%:5.6-cli
87-
RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \
88-
&& pecl install memcached-2.2.0 \
86+
FROM %%IMAGE%%:8.2-cli
87+
RUN apt-get update && apt-get install -y libmemcached-dev libssl-dev zlib1g-dev \
88+
&& pecl install memcached-3.2.0 \
8989
&& docker-php-ext-enable memcached
9090
```
9191

92-
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).
92+
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 compatibility when choosing a version of the extension to install, but does when trying to install it). 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.
9393

94-
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.
95-
96-
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.
97-
98-
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.
94+
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.2.0 && pecl install redis-5.3.7` instead of `pecl install memcached-3.2.0 redis-5.3.7`. However, `docker-php-ext-enable memcached redis` is fine to be all in one command.
9995

10096
### Other extensions
10197

10298
Some extensions are not provided via either Core or PECL; these can be installed too, although the process is less automated:
10399

104100
```dockerfile
105-
FROM %%IMAGE%%:5.6-cli
106-
RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \
107-
&& mkdir -p xcache \
108-
&& tar -xf xcache.tar.gz -C xcache --strip-components=1 \
109-
&& rm xcache.tar.gz \
101+
FROM %%IMAGE%%:8.2-cli
102+
RUN curl -fsSL '[url-to-custom-php-module]' -o module-name.tar.gz \
103+
&& mkdir -p module-name \
104+
&& sha256sum -c "[shasum-value] module-name.tar.gz" \
105+
&& tar -xf module-name.tar.gz -C module-name --strip-components=1 \
106+
&& rm module-name.tar.gz \
110107
&& ( \
111-
cd xcache \
108+
cd module-name \
112109
&& phpize \
113-
&& ./configure --enable-xcache \
110+
&& ./configure --enable-module-name \
114111
&& make -j "$(nproc)" \
115112
&& make install \
116113
) \
117-
&& rm -r xcache \
118-
&& docker-php-ext-enable xcache
114+
&& rm -r module-name \
115+
&& docker-php-ext-enable module-name
119116
```
120117

121118
The `docker-php-ext-*` scripts *can* accept an arbitrary path, but it must be absolute (to disambiguate from built-in extension names), so the above example could also be written as the following:
122119

123120
```dockerfile
124-
FROM %%IMAGE%%:5.6-cli
125-
RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \
126-
&& mkdir -p /tmp/xcache \
127-
&& tar -xf xcache.tar.gz -C /tmp/xcache --strip-components=1 \
128-
&& rm xcache.tar.gz \
129-
&& docker-php-ext-configure /tmp/xcache --enable-xcache \
130-
&& docker-php-ext-install /tmp/xcache \
131-
&& rm -r /tmp/xcache
121+
FROM %%IMAGE%%:8.2-cli
122+
RUN curl -fsSL '[url-to-custom-php-module]' -o module-name.tar.gz \
123+
&& mkdir -p /tmp/module-name \
124+
&& sha256sum -c "[shasum-value] module-name.tar.gz" \
125+
&& tar -xf module-name.tar.gz -C /tmp/module-name --strip-components=1 \
126+
&& rm module-name.tar.gz \
127+
&& docker-php-ext-configure /tmp/module-name --enable-module-name \
128+
&& docker-php-ext-install /tmp/module-name \
129+
&& rm -r /tmp/module-name
132130
```
133131

134132
## Running as an arbitrary user
@@ -163,7 +161,7 @@ The default config can be customized by copying configuration files into the `$P
163161
### Example
164162

165163
```dockerfile
166-
FROM %%IMAGE%%:7.4-fpm-alpine
164+
FROM %%IMAGE%%:8.2-fpm-alpine
167165

168166
# Use the default production configuration
169167
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

0 commit comments

Comments
 (0)