Opinion Piece: PHP: Why I love this productive, progressive programming language

Author: Matt Harvey, Staff Engineer at Ofload
I sometimes wonder, why is it that I feel so happy programming in PHP? What is it about this language that feels so right to me?
I’ve been using PHP in a full-time professional setting since joining Ofload in 2023 (though I used it for various side projects prior to that). One of the reasons I wanted to join Ofload was in order to work with PHP full-time.
One of the great things about PHP is its constant evolution, including its openness to adopting features first introduced by other programming languages. This year, for example, we are seeing PHP 8.5 introduce the pipe operator, |>, a convenience first seen in functional languages such as OCaml and Elixir.
Having said that, it's worth taking the time to celebrate the features that are unique to PHP (or at least, relatively unique among general-purpose languages), and that make it uniquely productive for developing web applications.
"Shared nothing" architecture
By default, PHP has a "shared nothing" architecture, which is arguably the simplest and most bulletproof conceivable way of serving a web application.
On each HTTP request, the application runs once, then dies. No in-memory application state is retained between requests.
This has a number of benefits, including:
- Simplicity: The request/response cycle is extremely easy to understand and build to
- Memory leak prevention: Memory leaks are practically impossible within the application layer
- Fault tolerance: State from one request cannot corrupt another
- Memory efficiency: In-memory data structures do not persist consuming memory between requests
It's worth noting that nowadays, the "shared nothing" architecture is not the only option. Performant, long-running architectures using tools like Roadrunner and Swoole are available for those who want to serve high-traffic PHP applications without incurring the overhead of a full application reboot per request. By default, however, the simple shared-nothing architecture is a great fit for the majority of web applications.
Fast startup time
PHP has been optimised from the outset to serve isolated web requests very efficiently. Therefore, it has an extremely fast startup time.
A consequence of this is that the development workflow is incredibly fluid. After making a change to a PHP file, the only thing needed is to refresh the browser (or other HTTP client) to see the effect. No complicated hot-reloading setup or compilation wait-time is required; the changes are immediately visible to the next web request.
Gradual, dynamic type system
PHP has a type system that can be used as strictly or as loosely as your needs require. Tools like PHPStan can be tuned to enforce consistent typing of function parameters, class properties, and so on. Alternatively, you can leave off all types in use cases such as small scripts that don't require a high level of type checking.
An interesting comparison here is with TypeScript. TypeScript also offers a gradual type system; however, it is almost completely erased at runtime. In contrast, PHP's types are available at runtime and can be reflected upon. In addition, PHP has no build step; the types you see in your editor are the types seen by the interpreter when your application runs.
(Some qualification is in order here: generics are, to the consternation of some, unknown to the interpreter even though they can be encoded via documentation comments and thus made formally available to static analysis tools.)
In my work at Ofload, we have been using PHPStan to gradually ratchet the strictness of our type usage over time. This has resulted in more a bullet-proof codebase, and an improved developer experience as our code becomes easier to reason about, navigate, and iterate on. PHPStan works in conjunction with the type system to check for code correctness without having to run the application.
PHP really gives us the best of both worlds in this sense: instant startup time (no build step), plus very good static type checking by virtue of PHPStan.
There are many other things about PHP that I love: the rich package ecosystem; the great development tools available (PHPStorm is fantastic); the robust, simple package manager in Composer; the straightforward syntax; and the pragmatic, multi-paradigm philosophy of the language.
At the end of the day, though, it’s about the “flow” for me. My head is largely “in the problem” or “in the feature” when I’m working in PHP. I’m not battling the language or the tools.
At Ofload, flow and velocity are critical; and so is quality, robustness. PHP gives us both.