Skip to content

Commit 6ea7f0a

Browse files
Run update.sh
1 parent b3bf4f3 commit 6ea7f0a

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

php/README.md

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

115115
```dockerfile
116-
FROM php:7.4-cli
116+
FROM php:8.2-cli
117117
COPY . /usr/src/myapp
118118
WORKDIR /usr/src/myapp
119119
CMD [ "php", "./your-script.php" ]
@@ -131,7 +131,7 @@ $ docker run -it --rm --name my-running-app my-php-app
131131
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:
132132

133133
```console
134-
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4-cli php your-script.php
134+
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:8.2-cli php your-script.php
135135
```
136136

137137
## How to install more PHP extensions
@@ -143,7 +143,7 @@ We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-instal
143143
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.
144144

145145
```Dockerfile
146-
FROM php:7.4-cli
146+
FROM php:8.2-cli
147147
RUN docker-php-source extract \
148148
# do important things \
149149
&& docker-php-source delete
@@ -154,7 +154,7 @@ RUN docker-php-source extract \
154154
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:
155155

156156
```dockerfile
157-
FROM php:7.4-fpm
157+
FROM php:8.2-fpm
158158
RUN apt-get update && apt-get install -y \
159159
libfreetype-dev \
160160
libjpeg62-turbo-dev \
@@ -178,59 +178,57 @@ Some extensions are compiled by default. This depends on the PHP version you are
178178
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:
179179

180180
```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 \
184184
&& docker-php-ext-enable redis xdebug
185185
```
186186

187187
```dockerfile
188-
FROM php:5.6-cli
189-
RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \
190-
&& pecl install memcached-2.2.0 \
188+
FROM php:8.2-cli
189+
RUN apt-get update && apt-get install -y libmemcached-dev libssl-dev zlib1g-dev \
190+
&& pecl install memcached-3.2.0 \
191191
&& docker-php-ext-enable memcached
192192
```
193193

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 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.
195195

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.
201197

202198
### Other extensions
203199

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

206202
```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 \
205+
&& mkdir -p module-name \
206+
&& sha256sum -c "[shasum-value] module-name.tar.gz" \
207+
&& tar -xf module-name.tar.gz -C module-name --strip-components=1 \
208+
&& rm module-name.tar.gz \
212209
&& ( \
213-
cd xcache \
210+
cd module-name \
214211
&& phpize \
215-
&& ./configure --enable-xcache \
212+
&& ./configure --enable-module-name \
216213
&& make -j "$(nproc)" \
217214
&& make install \
218215
) \
219-
&& rm -r xcache \
220-
&& docker-php-ext-enable xcache
216+
&& rm -r module-name \
217+
&& docker-php-ext-enable module-name
221218
```
222219

223220
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:
224221

225222
```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 \
230-
&& rm xcache.tar.gz \
231-
&& docker-php-ext-configure /tmp/xcache --enable-xcache \
232-
&& docker-php-ext-install /tmp/xcache \
233-
&& rm -r /tmp/xcache
223+
FROM php:8.2-cli
224+
RUN curl -fsSL '[url-to-custom-php-module]' -o module-name.tar.gz \
225+
&& mkdir -p /tmp/module-name \
226+
&& sha256sum -c "[shasum-value] module-name.tar.gz" \
227+
&& tar -xf module-name.tar.gz -C /tmp/module-name --strip-components=1 \
228+
&& rm module-name.tar.gz \
229+
&& docker-php-ext-configure /tmp/module-name --enable-module-name \
230+
&& docker-php-ext-install /tmp/module-name \
231+
&& rm -r /tmp/module-name
234232
```
235233

236234
## Running as an arbitrary user
@@ -265,7 +263,7 @@ The default config can be customized by copying configuration files into the `$P
265263
### Example
266264

267265
```dockerfile
268-
FROM php:7.4-fpm-alpine
266+
FROM php:8.2-fpm-alpine
269267

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

0 commit comments

Comments
 (0)