PHP 8.2 is out, and since PHP is still the foundation of how we build websites, why not give it a quick try. Thanks to deb.sury.org, it is available for Ubuntu and Debian almost immediately, so it's just a matter of running apt install. To avoid typing out the names of all the module packages I have installed for 8.1 by hand, I used the power of the Linux terminal, chained a few commands together and was done in no time:
dpkg -l | grep php8.1 | awk '{print $2}' | tr -s "\n" " " | sed -e "s/php8\.1/php8.2/g" | xargs sudo apt install -y
What the individual parts do:
- dpkg -l - lists all installed packages
- grep php8.1 - filters only the packages that contain php8.1
- awk '{print $2}' - the output has several columns and the php8.1 package name is in the second one
- tr -s "\n" " " - the output is line-based, i.e. each package on a new line; this turns it into a single line by replacing the newline character with a space
- sed -e "s/php8\.1/php8.2/g" - replaces php8.1 with php8.2 in the package names. Replacing just the digit would not be enough: when upgrading from 8.2 to 8.3,
s/2/3/gwould turn libapache2-mod-php8.2 into the non-existent libapache3-mod-php8.3 - xargs sudo apt install -y - xargs passes the resulting line as an argument to the apt install command with the required sudo, and the -y option automatically confirms all changes
For distributions other than Debian and Ubuntu clones, the command would most likely need substantial changes. But it can certainly serve as inspiration