You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
@@ -41,7 +41,7 @@ We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-instal
41
41
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.
42
42
43
43
```Dockerfile
44
-
FROM %%IMAGE%%:7.4-cli
44
+
FROM %%IMAGE%%:8.2-cli
45
45
RUN docker-php-source extract \
46
46
# do important things \
47
47
&& docker-php-source delete
@@ -52,7 +52,7 @@ RUN docker-php-source extract \
52
52
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:
53
53
54
54
```dockerfile
55
-
FROM %%IMAGE%%:7.4-fpm
55
+
FROM %%IMAGE%%:8.2-fpm
56
56
RUN apt-get update && apt-get install -y \
57
57
libfreetype-dev \
58
58
libjpeg62-turbo-dev \
@@ -76,59 +76,57 @@ Some extensions are compiled by default. This depends on the PHP version you are
76
76
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:
77
77
78
78
```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 \
82
82
&& docker-php-ext-enable redis xdebug
83
83
```
84
84
85
85
```dockerfile
86
-
FROM %%IMAGE%%:5.6-cli
87
-
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).
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.
93
93
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.
99
95
100
96
### Other extensions
101
97
102
98
Some extensions are not provided via either Core or PECL; these can be installed too, although the process is less automated:
103
99
104
100
```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 \
&& tar -xf module-name.tar.gz -C module-name --strip-components=1 \
106
+
&& rm module-name.tar.gz \
110
107
&& ( \
111
-
cd xcache \
108
+
cd module-name \
112
109
&& phpize \
113
-
&& ./configure --enable-xcache \
110
+
&& ./configure --enable-module-name \
114
111
&& make -j "$(nproc)" \
115
112
&& make install \
116
113
) \
117
-
&& rm -r xcache \
118
-
&& docker-php-ext-enable xcache
114
+
&& rm -r module-name \
115
+
&& docker-php-ext-enable module-name
119
116
```
120
117
121
118
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:
122
119
123
120
```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 \
0 commit comments