`docker-php-ext-install opcache` works with PHP 8.4 but not PHP 8.5 [closed]

2 weeks ago 15
ARTICLE AD BOX

As documented in the PHP 8.5 changelog, since PHP 8.5 the Opcache extension now always ships with PHP (non-optional). So you don't need to install it any longer.

Opcache: Make OPcache non-optional (Arnaud, timwolla)

Using zend_extension=opcache.so or zend_extension=php_opcache.dll INI directives will emit a warning.

If you're looking for the backward incompatible changes of the now non-shared opcache extension, see section Opcache in appendix Migrating from PHP 8.4.x to PHP 8.5.x of the PHP Manual for the whole picture.

Official PHP Docker image builds adopted to that already prior to PHP version 8.5.0 release that was yesterday (at the time of asking). (ref)

One reason is, that the Docker library PHP image nowadays has better support for RC candidates. If you make use of them earlier (e.g. to stage your PHP version migrations), this would also be helpful in testing the new releases. Maybe next time? It's a win-win!


Note: Under circumstances you may need to enable it (because Opcache as a feature still can be disabled). This is not the case with all official image builds (PHP 8.5...).

RUN /bin/sh -c 'if php -m | grep -qi "$1$"; then \ printf "%s already installed\n" "$1"; \ else docker-php-ext-install -- "$1"; fi' -- \ opcache

Listing 1: Install PHP Opcache (if not yet installed)

RUN docker-php-ext-enable opcache || true

Listing 2: Enable PHP Opcache (with allow failure) (ref)

Read Entire Article