1464 1667 1893 1462 1852 1527 1214 1593 1635 1533 1031 1183 1218 1701 2000 1878 1505 1455 1693 1373 1444 1698 1527 1202 1349 1374 1725 1887 1170 1762 1979 1316 1669 1841 1226 1332 1595 1838 1257 1659 1509 1650 1011 1616 1525 1039 1624 1306 1834 1384 1142 1167 1032 1566 1763 1445 1353 1736 1778 1934 1643 1379 1680 1233 1756 1560 1970 1014 1587 1248 1384 1844 1017 1008 1167 1218 1056 1468 1715 1725 1881 1789 1432 1282 1246 1192 1211 1527 1724 1410 1209 1200 1611 1683 1487 1780 1345 1263 1423 PHP in 2021 | PHPnews.io

PHPnews.io

PHP in 2021

Written by Stitcher.io / Original link on Apr. 15, 2021

Once a year, I look back at the recent developments in the PHP world, and also look forward to what's to come. And just like in 2020 and 2019, we're at it again!

Like I said time and time again: PHP isn't the same language it was ten years ago, and we're very thankful for that. It's a fast and reliable language, used to build large applications at scale. So let's discuss some of the most notable changes of PHP in the last year, to the language and the community.

Noticed a tpyo? You can submit a PR to fix it. If you want to stay up to date about what's happening on this blog, you can follow me on Twitter or subscribe to my newsletter: Email Subscribe

# PHP 8 and beyond

The new major version, PHP 8, arrived late last year. I've written an extensive amount on the topic, and I won't copy/paste all of that here. As always, performance is only improving, as shown by the benchmarks done by Kinsta.

There's also the JIT that does seem to improve performance of some projects here and there, as well as preloading that has an overall positive impact if you're not using shared hosting.

I think that features like attributes (a.k.a. "annotations"), named arguments and promoted properties also deserve a mention, as they have definitely contributed towards PHP 8 being such a great release.

Meanwhile, the core team is already working on the next version, PHP 8.1, which will be released somewhere by the end of 2021. For now, the most significant features are enums and fibers, I'll mention both of them again later in this post.

Year after year, the core team succeeds in bringing a new stable release to the community, packed with a bunch of features and quality-of-life improvements. The upgrade path also isn't all that difficult anymore. I upgraded some of my own projects from PHP 7.4 to PHP 8, and it took only an hour or so per project. There really isn't any good reason to stay behind!

Tired of managing servers? Check out Serverless Visually Explained by Matthieu Napoli and learn how to create scalable PHP applications on AWS.

# PHP's type system

There's actually some very exciting news when it comes to types: enums will be added in PHP 8.1. On top of that we've also seen some of the maintainers of static analysis tools contributing to PHP's source code by landing their first RFC. This one adds the never type, a useful addition for static analysis.

Speaking of static analysis tools, PhpStorm has added built-in support for Psalm and PhpStan, which is a great step towards broader adaptation.

Still no support for generics, unfortunately. There are some major road blockers, especially since we're still dealing with a dynamically typed language. Nikita has outlined the problems here. Personally, my approach would be the easy way out: only support runtime-erased generics and rely on static analysis. This requires more than a technical solution though, it also requires a mind shift in the PHP community as a whole. Maybe one day it becomes a viable option, but not as of yet.

# Async PHP

There was some big news recently: PHP is getting coroutines — aka. green threads — in PHP 8.1! Although, fibers — that's what they are called — might not be as big a game-changer as you might think.

Even though fibers themselves might only be a small cog in what is the large async machine, the RFC has spiked interest in the async community again, which we can only be happy about. Async frameworks like Amphp and ReactPHP are growing in popularity, and recently Laravel announced built-in support for Swoole.

# The community

I can't go on without mentioning Composer, the de-facto standard package manager. It has had a new major release in October, 2020: Composer 2.0. This version comes with several UX improvements, but most importantly sees extreme performance improvements, sometimes even tripling its speed on clean installs.

Speaking of composer, I like to measure the current state of PHP's ecosystem by looking at the available packages over time. Last year I spoke about ±25 million downloads a day, today that number has more than doubled and we're looking at ±60 million daily downloads.

Finally, take a look at this graph, listing the amount of packages and versions over time. It can also be found on their website. You can clearly see a healthy ecosystem growing, and there's no end in sight.

01.png

# The language

Let's end with a reminder of everything that's been added to PHP these recent years. If you haven't kept up with its development, you really want to check this list out. I think it shows the growth of the community and core development team within recent years, and I'm confident there's more to come.

Noticed a tpyo? You can submit a PR to fix it. If you want to stay up to date about what's happening on this blog, you can follow me on Twitter or subscribe to my newsletter: Email Subscribe

All of that to say: PHP is alive and doing very well. Every year I feel happier with the direction the language is going, and am looking forward to using it for many years to come!

If you're excited as well, you probably want to subscribe to my newsletter to stay up-to-date about PHP's development, as well as follow me on Twitter. Let me know your thoughts via Twitter or email, and share this post with your audience if you found it useful, thanks!

stitcher.io

« PHP Internals News: Episode 81: noreturn type - Self hosting Google Fonts »