Why I Continue to Write PHP

Lochemem Bruno Michael
4 min readMar 19, 2018
PHP elephant (Image courtesy of Pixabay)

It is no secret that PHP has declined in popularity in recent years. The explanations for the decline of one of the web’s darlings are quite colorable: the rise of JavaScript, the growth of more robust languages, and the inefficiencies of the PHP language core. I get a lot of scorn for writing PHP code — the purpose of this article is, therefore, a justification for my stubbornness. I not only intend to show exactly why I continue to write PHP code but also hope to dispell certain notions about the language.

PHP has improved significantly

The best place to start my defence is by dismissing a common fallacy — PHP is not potent enough. PHP has new features which make it a robust solution for server-side programming-related problems. Chief among the new additions are the enhancements to the Zend and HHVM engines which have drastically increased language performance. Also, the additions to the versions of the language 7.0 and upwards have marked overall improvement in coding experience.

Among the additions are anonymous classes, modern cryptography with the inclusion of libsodium and Argon2 packages, return type hint capability, and new operators — spaceship as well as null-coalesce operators. The language also has a Read Evaluate Print Loop (REPL) contrary to popular belief and has had one since the 5.1.0 release.

Reader monad usage in the PHP REPL

PHP’s revived potency is such that one can write applications that run beyond the standard web environment. Command Line Interfaces (CLIs) and daemons can be idiomatic PHP implementations. Take Composer for example, PHP’s defacto package manager: it runs a PHP Archive (.phar) file which helps install and manage PHP packages.

The bingo-functional REPL built in vanilla PHP

If affirmation from Lord Rasmus, creator of the best language in the world, is what you need, check out this video from the We Are Developers conference from 2017. In the video, Mr Lerdorf (Dumbledore in disguise), discusses the evolution of the language.

Functional Programming is Possible in PHP

The current zeitgeist of programming, the functional programming paradigm, can be used in PHP too. Though not organically built to support functional programming, PHP’s current specification suffices to this end. From composing functions to using Applicatives and Monads, PHP has a variety of tools to help ease the process of reducing the cognitive burden. Check out my series on Functional Programming in PHP — rumor has it, I’m writing a book on the same topic. Oh, check out my library too.

Experimenting with PHP is fun

Closely related to the functional programming experience in PHP is the experimentation that comes with the language’s many downloadable utilities. Parallelizing tasks with the php-amqp library and RabbitMQ message broker is particularly interesting. Doing this enters the loosely coupled communications conversation space — sending data to many services and monitoring data feeds are immanent in this discourse.

Additionally, pushing the boundaries of PHP by attempting asynchronous operations using the react-php library is quite cathartic. Most of the disdain for PHP stems from its default synchronous nature — going against the grain can be mentally reassuring.

PHP-JavaScript is one hell of a Combo

The Chadwick Boseman to the web’s Ryan Coogler, JavaScript, is quite the technological marvel. Its numerous perks and flaws complement those of its distant sibling, PHP. Also, JS is asynchronous and powers front-end as well as back-end systems. I find that a healthy dose of a PHP-back-end and JS front-end can be quite maddening to conceive but beautiful to behold.

Combining functional programming in PHP with the modularity of a React-Redux-workflow can be quite exciting. Serving data to a JS-driven front-end service by using well crafted private API’s, I find, separates concerns nicely. Furthermore, frameworks like Symfony and Laravel make bootstrapping a PHP application a breeze. The latter has bindings for vue-js and a webpack configuration abstraction.

In conclusion, a lot remains on the horizon for PHP. Like most things, PHP needs to evolve and might continue to get better with the introduction of a Just-In-Time compiler. Ever since I first wrote PHP code in 2014, my life has not been the same. The sentimental value PHP has in my life is expressed in how passionately I endorse the language. I do not intend to spur argument and strife as I acknowledge that everyone has a preference — mine just happens to be PHP.

--

--