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:
@@ -143,7 +143,7 @@ We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-instal
143
143
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.
144
144
145
145
```Dockerfile
146
-
FROM php:7.4-cli
146
+
FROM php:8.2-cli
147
147
RUN docker-php-source extract \
148
148
# do important things \
149
149
&& docker-php-source delete
@@ -154,7 +154,7 @@ RUN docker-php-source extract \
154
154
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:
155
155
156
156
```dockerfile
157
-
FROM php:7.4-fpm
157
+
FROM php:8.2-fpm
158
158
RUN apt-get update && apt-get install -y \
159
159
libfreetype-dev \
160
160
libjpeg62-turbo-dev \
@@ -178,59 +178,57 @@ Some extensions are compiled by default. This depends on the PHP version you are
178
178
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:
179
179
180
180
```dockerfile
181
-
FROM php:7.4-cli
182
-
RUN pecl install redis-5.1.1 \
183
-
&& pecl install xdebug-2.8.1 \
181
+
FROM php:8.2-cli
182
+
RUN pecl install redis-5.3.7 \
183
+
&& pecl install xdebug-3.2.1 \
184
184
&& docker-php-ext-enable redis xdebug
185
185
```
186
186
187
187
```dockerfile
188
-
FROM php:5.6-cli
189
-
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).
194
+
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.
195
195
196
-
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.
197
-
198
-
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.
199
-
200
-
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.
196
+
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.
201
197
202
198
### Other extensions
203
199
204
200
Some extensions are not provided via either Core or PECL; these can be installed too, although the process is less automated:
205
201
206
202
```dockerfile
207
-
FROM php:5.6-cli
208
-
RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \
209
-
&& mkdir -p xcache \
210
-
&& tar -xf xcache.tar.gz -C xcache --strip-components=1 \
211
-
&& rm xcache.tar.gz \
203
+
FROM php:8.2-cli
204
+
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 \
208
+
&& rm module-name.tar.gz \
212
209
&& ( \
213
-
cd xcache \
210
+
cd module-name \
214
211
&& phpize \
215
-
&& ./configure --enable-xcache \
212
+
&& ./configure --enable-module-name \
216
213
&& make -j "$(nproc)" \
217
214
&& make install \
218
215
) \
219
-
&& rm -r xcache \
220
-
&& docker-php-ext-enable xcache
216
+
&& rm -r module-name \
217
+
&& docker-php-ext-enable module-name
221
218
```
222
219
223
220
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:
224
221
225
222
```dockerfile
226
-
FROM php:5.6-cli
227
-
RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \
228
-
&& mkdir -p /tmp/xcache \
229
-
&& tar -xf xcache.tar.gz -C /tmp/xcache --strip-components=1 \
0 commit comments