PHP 2019: Better Than You Think About It

Original author: Brent
  • Transfer

Remember the once-popular post: “ PHP: A Fractal of Bad Design ”? When I first read it, I worked in a stupid place with a lot of outdated PHP projects. She made me wonder if I should leave and do something completely different than programming.

Fortunately for me, soon I was able to change my place of work, and, more importantly, PHP was able to "slightly" evolve since the 5. * version. And today, through this article, I want to appeal to people who either no longer program in PHP or are stuck in legacy projects.

Spoiler: Today, PHP, like almost every programming language, is full of flaws. Many basic functions still have inconsistent signatures, configuration settings are confused, there are still a lot of developers writing shitty code, because in their current project it doesn’t work differently or because they don’t know otherwise.

Today, I want to take a look at the bright side: let's focus on what has changed and how to write clean and maintained PHP code. I want to ask you to drop prejudice for a few minutes.

After that, you can think of PHP exactly the same as before. Although, most likely, you will be surprised at some of the improvements made in PHP over the past few years.


  • PHP is actively developed, a new release is released every year
  • Performance from the PHP 5 era doubles, if not triple
  • There is an extremely active ecosystem of frameworks and libraries
  • Over the past few years, many new features have been added to PHP, and the language continues to evolve.
  • Tools like static analyzers have evolved a lot in recent years and continue to evolve further.

Short story

A brief look at the PHP release cycle. The current version is PHP 7.3, and version 7.4 is expected at the end of 2019. PHP 8.0 will be the next version after 7.4. Beginning in the late era of PHP 5. *, the team of maintainers has been trying to maintain an annual release cycle, and it has been doing very well over the past four years.

In general, each new release is actively supported for two years and receives another year of “security fixes”. The goal is to motivate PHP developers to keep the version current: applying small updates every year is much easier than, for example, switching from 5.4 to 7.0.

An updated calendar of support dates for different versions of PHP can be found here .

Finally, PHP 5.6 was the last release of the 5. * branch, and 7.0 was the next. If you want to know what happened with PHP 6, you can listen to the PHP Roundtable podcast .

Now let's debunk some common misconceptions about modern PHP.

PHP performance

In days of version 5. * PHP performance was ... average, at best. However, in version 7.0, significant parts of the PHP core were rewritten from scratch, resulting in a performance increase of two to three times.

But words are not enough. Let's look at the tests. Fortunately, other people spent a lot of time benchmarking PHP performance. I believe Kinsta has a nice updated list.

Starting with version 7.0, performance is only increasing. So much so that PHP web applications have comparable, and in some cases better performance than web frameworks in other languages. Take a look at this extensive test suite.

Of course, PHP frameworks will not outperform C and Rust, but they are much better than Rails or Django, and comparable to ExpressJS.

Framework and ecosystem

Speaking of frameworks: PHP is no longer limited to WordPress. I can tell you as a professional PHP developer: WordPress is by no means a representative of the modern ecosystem.

In general, there are two main web application frameworks: Symfony and Laravel . And a few smaller ones: Zend, Yii, Cake, CodeIgniter, etc. But if you want to know what modern PHP development looks like, a good choice would be to get to know one of the two largest.

Both frameworks (Symfony and Laravel) have a large ecosystem of packages and products. From administrative panels and CRM to stand-alone packages (in the original - “standalone packages”), from CI to profilers, as well as numerous services such as web socket servers, queue managers, payment integration; frankly, too much to list everything.

However, these frameworks are intended for direct development. If you just need to manage your content, platforms like WordPress and CraftCMS are only getting better.

One way to measure the current state of the PHP ecosystem is to look at packagist, the main package repository for PHP. It is growing exponentially. With ~ 25 million downloads per day, we can rightly say that the PHP ecosystem is no longer the weakness that it used to be.

Take a look at this graph, which shows the number of packages and versions over time. It can also be found on the packagist website .

In addition to application frameworks and CMS, in recent years we have also seen an increase in asynchronous frameworks.

These frameworks and servers, written in PHP or other languages, allow the use of truly asynchronous PHP. Examples include Swoole , Amp, and ReactPHP .

Since we entered the asynchronous world, things like web sockets and applications with many I / O operations have become really relevant in the PHP world.

The internals mailing list - a place where leading developers discuss language development - also talked about adding libuv to the kernel. For those who do not know libuv, this is the same library that Node.js uses to ensure all its asynchrony.

Language itself

Although async and await are not yet available, in recent years many improvements have been made to the language itself. Here is an incomplete list of new features in PHP:

  • Arrow functions
  • Union operator with null
  • Traits
  • Typed Properties
  • Unpack operator
  • Jit compiler
  • External function interface
  • Anonymous classes
  • Return Type Declaration
  • Modern cryptography
  • Generators
  • Much more

While we are talking about language features, let's also touch on the topic of how language is developing today. There is a team of volunteer maintainers who move the language forward, while the community can also offer RFCs.

These RFCs are then discussed on the internals mailing list, which can also be read on the Internet. Before a new language feature is added, a vote must be taken. Only RFCs with a majority of votes, at least ⅔ of all voters, are allowed to be included in the core.

About 100 people take part in the voting, and there is no requirement to vote on each RFC. The group of people who have the opportunity to vote, of course, includes the maintainers, because they must maintain a code base. In addition to them, there is a group whose members were selected individually from the PHP community. This group consists of PHP documentation maintainers, authors of major PHP projects, and prominent developers from the PHP community.

Although most of the development is on a voluntary basis, one of the core PHP developers, Nikita Popov, was recently hired by JetBrains to work on the language full time. Another example is the Linux Foundation, which recently decided to invest in the Zend Framework. Such work and acquisitions guarantee stability for the future of PHP and its development.


Besides the core itself, over the past few years we have seen an increase in the tools around it. Psalm static analyzers such as those created by Vimeo, Phan, and PHPStan come to mind .

These tools statically analyze your PHP code and report any typical errors, possible bugs, etc. In a sense, the functionality they provide can be compared to TypeScript (translator's note: static analyzers expand the language's ability to search for errors / defects thereby improving the language, TS conditionally does the same thing on top of JS) , although at the moment the PHP language is not transpilable, so custom syntax is not allowed.

Although we still have to rely on dockblocks and typing, Rasmus Lerdorf, the creator of PHP, mentioned the idea of ​​adding a static analysis mechanism to the kernel. This task contains a lot of potential, but it is huge in terms of labor costs.

Speaking of transposition, it is worth noting that there were attempts to expand the PHP syntax not at the kernel level, but at the level of user libraries, as implemented in JavaScript. A project called Pre does just that: it allows you to use the new PHP syntax that wraps into regular PHP code.

Although this approach has proven itself in the JavaScript world, it can only make money in PHP if proper support is provided for IDE and static analysis. This is a very interesting idea, but it has a long way to go before it can be called the mainstream.


Despite all this, feel free to think of PHP as a terrible language. He definitely has his flaws and a 20-year heritage, but I can confidently say that I like working with him.

With it, I can create reliable, well-maintained and high-quality software. The clients I work for are happy with the end result, just like me.

Despite the fact that you can still write very bad code when working with PHP, I would say that this is a great choice for web development, if used correctly.

Do you disagree? Write in comments why!

Also popular now: