Why I moved on from PHP

To put it simply, I do not enjoy where PHP frameworks are headed

Note: At the time of writing this warning, this post is over 2 years old. I no longer use ExpressJS and have moved on to socket based applications instead.

Do not get me wrong, I love PHP for the most part. I have been using it for years and I have to thank PHP for where I am right now. It has built opportunities for me that I otherwise possibly wouldn’t have gotten.

Unfortunately, it has become clear that I need to make some changes. Up until now, I have been using the Phalcon framework to develop my web projects. However, starting PHP 8.0 they have announced that they were switching to “native” PHP which is just a fancy way of saying that they’re going to be switching to being a framework based solely on PHP…just like Laravel and Symfony. The only reason I was using Phalcon was because it’s really an extension you can just install and have amazing performance just because of that. Plus, they have little to no implementations like authentication which allowed me to do that myself… which is exactly what I was looking for!

I’m afraid that will no longer be a thing. Also, the development for that framework in particular is really unpromising, their team is small. I do not want to take the risk of using Phalcon for all of my future projects, only to find I am using an unmaintained framework.

So I went looking for alternatives. There are no real alternatives, outside of just going ahead and writing my own PHP framework, which is what I did up until switching to Phalcon. The reason I’m not using something like Laravel? Its performance is terrible (unless you cache everything, but does that really solve the problem?) and it’s an extremely abstract framework. I want to implement things myself. I don’t want things to “just work”, without knowing the underlying technology. I don’t want to rely on someone else to provide security for my projects. That’s something I want to have in my own hands.

Having realized at this point that most PHP frameworks just aren’t for me, not because I can’t use them, but because they don’t allow much freedom, I considered writing my own PHP framework again. But do I really want to deal with that? It’s almost like I am contradicting myself… I want more control but when I have the option, I don’t want to deal with it… but hear me out.

Writing my own PHP framework would require me to implement routing and a controller & view + model system myself and I would’ve done that, had I not been introduced to the Phalcon framework that handled those things amazingly. I came to realize that I don’t want to deal with those things at all.

So to be clear, yes, I want more control over how my application functions, but things like routing should be trivial and easy to go about. I shouldn’t have to write my own framework that’s maintained by a large group of people: me, I and myself. Furthermore, it wouldn’t make much sense. My framework would be in “native” PHP, which is exactly the same route Phalcon is taking. Could as well just use Phalcon at that rate again.

So. I needed an alternative. An alternative to the thing we call PHP itself. I do not want to give up my control for abstraction and less performance. I do not want to rely on too much implementation by other people, as in, I want to implement some sensitive things myself to ensure its security and performance.

That’s where it hit me. I remember using express.js at one point. Even its slogan is very promising. It is an unopinionated framework, just like Phalcon is. You do a lot of things yourself, and that’s exactly what I am looking for! Plus, it has basic things like routing and MVC already implemented right out of the box! Plus, it’s NodeJS. I’ve wanted to move on for a while, and seeing how performant the vast majority of the applications based on Express are, I’ve determined that it might be the right choice moving forward.

After tinkering around with it for a little bit, I have come to the conclusion that it is indeed what I am looking for. No more setbacks from PHP being PHP, and not a compiled language in itself unless you use OPCache which feels hacky, plus it’s served through fastcgi, which cannot be good for performance whatsoever. I am aware that PHP8 ships with JIT and all those “magical” work-arounds… but they’re not really solving the issue itself, just patching it like you would with bandaid and toiletpaper. NodeJS is not compiled in ways things like C++ are, it is compiled once you run it once, unlike PHP that has the tendency to go through all of that again every single request which hurts performance terribly. Not to mention all of those frameworks that sit on top of that like Luigi’s spaghetti…

So ExpressJS it is! None of my future projects, if I have the choice, will be using PHP. It’s time to move on.