Everyone in the PHP community is really excited about the upcoming new major version as it features a bunch of cool things like JIT, annotations and so on. I won’t make a list of what’s to come as there are many articles online for that, just search for “PHP 8 features” in your favourite search engine, click on the first link and you’re basically done.
I’d rather focus on what we need to do before upgrading. Or for some items, what we need to wait for and even better the projects that would enjoy a little help.
Important tools to update
PECL is dead, long live Pickle
Pear being in a no man’s land during the last few years, it has been decided to deprecate its usage and to completely remove it starting from PHP 8 (who took care of the ugly notices about accessing an array offset on a bool value every time we run it ?). That’s a big deal because the PECL executable is part of Pear.
Good news is: some folks from FriendsOfPHP are working on a replacement called Pickle, its Github repository is here: https://github.com/FriendsOfPHP/pickle . But even if the guys were pretty active on its development this year, it’s not finished. As of now, the latest version is 0.6.0 and it globally works fine but unfortunately it’s not able to install XDebug. Oops.
Pickle is easy to install (no compilation needed), and only requires
zip as a system dependency (besides
PHP obviously). Let’s say you want to install it in
wget https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar -O /usr/bin/pickle chmod +x /usr/bin/pickle
And it’s as easy as PECL was:
pickle install firstname.lastname@example.org
(assuming I explicitly want version 1.8.1)
If you’re using PHPUnit on a project started some years ago like a lot of people do, you’re probably using an old version, like 7 or 8. PHPUnit 9 is the only major version that supports PHP 8, so you’ll have to upgrade (no more postponing that task!). Let’s hope you didn’t overused annotations because it was removed from PHPUnit in version 9 …
If you’re a MongDb user
The Mongodb driver must be updated
That’s a side-effect of several changesets applied to PHP’s codebase, some extensions are not compiling anymore. The Mongodb driver is one of them and it’s unclear if it needs a lot of work before it compiles on both major version. Just keep an eye on this discussion to stay informed on the task’s progress: https://github.com/mongodb/mongo-php-driver/issues/1161
A repository to test the installation of a fresh PHP 8 stack
I’ve setup a small repository on Github to test the installation of a PHP 8 stack made of “classical” stuff we frequently use:
- xdebug The first build made with PHP 7.4 worked but after merging PHP’s major version bump, things are not going so well anymore. Feel free to visit the latest build status if you’re curious about how things evolved since this post went online.