PHP turns 25! Here’s a brief retrospective of its evolution - Questers

PHP turns 25! Here’s a brief retrospective of its evolution

Светлин СтаевOn the occasion of the 25th anniversary of PHP, we invited our colleague Svetlin Staev, a Lead Software Engineer in the News UK team at Questers, to make a brief retrospective of the language’s evolution. Although in his current work he uses a technology mix of React Native Web, GraphQL and JavaScript, Svetlin has almost 20 years of experience in developing web systems and applications with PHP and has closely observed how has the language changed over the years. Read what he shared about his special relation with it:

For as many years as I can remember PHP has been just like that most popular girl in high school. Yeah, that perfect one. That one, everyone wants to take to the prom. That one that all quite so eagerly look for when they enter the room. Some would argue that she is not that perfect at a single thing. Others will praise every bit of her. Indeed, time and time again, it has proven to be a true love/hate relationship at best. But regardless of what many would argue even in this age of overly immersive visuals and powerful interactions, that “one” without all these bells and whistles still boosts more than 75% of web.

Of course, I am not talking about some mystery girl here, but rather a relationship with a language I have had for close to 20 years – PHP. While this whole analogy might be a bit far-fetched, coming up to its 25th anniversary I utterly believe it still holds true, at least for me. PHP is far from perfect and for many years has received a bad reputation over producing messy and insecure code, having an inconsistent standard library and subpar performance. But it has undoubtedly had the chance to lay the very groundwork to the modern web as we know it and has done the very best job at it. It has transformed the static Web we knew in the mid-90s to something far more dynamic and richer in functionality – from empowering one of the first forum (phpBB) and blog (WordPress) platforms to being one of the first building blocks to giant systems like Facebook, Yahoo and Wikipedia.

Humble Beginnings

The very first version of the language was created in 1994 by Rasmus Lerdorf for a personal project to track visits to his online resume. He blatantly named it “Personal Home Page Tools”, a name that is not very well known by many. The “PHP: Hypertext Preprocessor” or just PHP came only after a couple of years after two guys (Andi Gutmans and Zeev Suraski) decided to use the code, Rasmus had open-sourced, for an eCommerce application they were building for a university project.

With hobby projects in mind or not, being very much a general-purpose, dynamic language with familiar C-like syntax, it just picked up in popularity and over the course of the next two decades, it has been vigorously adding feature after feature to unleash new possibilities for more interactive web sites while still having a very low learning curve. Want to create a script to process some data - you are covered! How about a database – sure, as easy as a couple of lines of code! Make a blog – simply embed the business logic and some HTML, and you are good to go.

With many small “scripts” in place, businesses were able to launch sites in record times in the post-dot-com era. But the Web was evolving, quite so rapidly, the need for larger-scale sites was emerging and the question was “Could this language deliver?”. Surely, every new version brought more performance improvements and cool features most notable out of the pack:

  1. The improved object model in PHP 5.0
  2. PDO for easier database access in PHP 5.1
  3. Native JSON support in PHP 5.2
  4. Namespace support and closures in PHP 5.3
  5. Built-in web server, traits, generators, variadic functions by the end of version 5
  6. Long-anticipated stricter types in PHP 7.x

But what I believe was missing for that large-scale to be possible was not solely in the language itself but also in the ecosystem in that era. It was missing powerful abstractions and quality frameworks to propel it to the next level.

The Renaissance of Abstractions

While initially, the language so freely allowed the inexperienced developer to just mix it with any given HTML code, it was simply not maintainable for large projects. It wasn’t until some frameworks like Symfony, Zend Framework, Laravel and Yii were developed that this gave the developers the much-needed structure to build the next big monolith out of small well-crafted blocks:

  1. Request/Response abstractions like Symfony HttpFoundation Component
  2. Dependency injection containers like Zend Service Manager, Symfony DI Component and Pimple
  3. Routers like Symfony Routing Component and Fast Route
  4. Templating engines like Twig, Blade and Smarty
  5. Database abstraction libraries and ORMs like Propel, Doctrine and Eloquent
  6. Event managers
  7. Form management like Symfony Form Component

Inspired by powerful design patterns, many of these components and frameworks were abstracting just the right primitive concepts, making even a project of hundreds of thousands of files easier to manage and reason about.

In that period of the explosive growth of the PHP ecosystem, an honourable mention is to the project I strongly believe gave the biggest boost to it all – Composer, the PHP package manager. Such a simple concept should have been there from the very beginning. And while it was attempted at first by PEAR project in the early days of PHP, it wasn’t until 2012 that Composer transformed the way to use the dependencies in our projects similarly to how npm and bundler did for their respective languages.

The best is yet to come

PHP has gone through a whole lot from a simple hobby project to a language that can very well be suited for writing highly scalable and complex systems. The Web landscape has been observing a shift towards more and more API-driven single-page apps with JavaScript handling most of the business logic, but by no means does this takes PHP’s place on the table.

The next version 8 is scheduled for the end of this year and alongside a few new and exciting features like attributes, union types and weak maps, the community is eagerly awaiting the brand-new JIT compiler which could bring new levels of performance optimizations. The static typing in PHP is constantly improved with every new subversion and it won’t be long until it gets all the goodies from languages like C++ and Java. Further, the trend of asynchronous programming has inspired projects like Swoole, ReactPHP and Amp that could close the gap with strong contenders like Node.JS. Without any doubt, the best years of the language are yet to come, and all of us which are still in love with it, are anxiously awaiting it.