You could use the following to install the current versions of all the PHP packages provided provided by
apt install $(grep-aptavail -S php-defaults -s Package -n)
(You’ll need to install
This uses two commands:
grep-aptavail -S php-defaults -s Package -n
searches the packages
apt knows about, looking for a source package (
-S) matching “php-defaults”, and listing matching binary packages (
-s Package) without the field name (
-n); the result is used, via command substitution, as arguments to
which installs the packages.
This will install the default version of PHP and all the extensions provided by PHP, and ensure that they are upgraded as new versions become the default (so when you upgrade from Debian 9 to Debian 10, and PHP 7.3 becomes the default instead of PHP 7.0, all your PHP 7.0 extensions will be upgraded to 7.3). However you’d need to re-run the command to pick up new extensions, and clean up obsolete ones separately.
You could adapt this to install every package which depends on
php-common, which would bring in all the available PHP extensions, but that ends up installing far more packages than makes sense.