PHP is good

Mikołaj Sodzawiczny

Mikołaj Sodzawiczny / June 24, 2023

5 min read

There, I said it!
I recently started using PHP to build my PaaS that I am planning on launching pretty soon. Even thought I understand that "php this, php that" is sort of a meme, it still discouraged me from using it. In this post I want to write about what has changed and why YOU should also give PHP a try.

Beginning

At my current job we use a lot of PHP, at first I was quite surprised but I didn't want to dismiss the actual technology. Heck, if I ever want to help out the backend team I am expected to know some PHP and I am not going to scream "REWRITE IT!!!". So I started learning and well, I was surprised.

Feeling of the language

That's probably the most subjective category amongst programming languages, but I highly value how the language feels. I like when it's easy to read and doesn't have a lot of gotcha's (looking at you c++). I also highly care about the ecosystem of a given language. If I have to make a production ready service/tool I will probably not be using a vanilla version of the language. Not a lot of people write vanilla js and I don't think a lot of people write platforms using vanilla PHP (even though they probably could).

But that's all just my rambling about how I feel - matters to me but probably not much to you. Now I want to introduce a lttle guideline which helps me immensly in choosing what I want to learn - here it is - if it doesn't change my approach to software engineering and doesn't expand my horizons I don't think it's worth learning. Obviously your milage may vary, but I want to give a straight forward example to illustrate what I mean. Learning GO perhaps is not the hardest task and you can pretty much get up to speed in about 2 weeks if you already know how to program. Even thought it's not difficult, you can add to it docker and how to design microservices. Because the language is simple and very powerful you can squeeze a lot out of it in its natural field of application. Servers, microservices and itterating often is where GO shines and once you learn it it opens a lot of possibilities for you. It's really in demand, highly paid and just overall nice to use - sounds great to me!

So what did I learn while exploring PHP?

PHP shines when you want to learn about DBM, Relational DB and how servers work. On top of that MVC is a very straight forward concept to grasp if you pair it with Laravel or Symfony. Really makes you think about how to compose (wink wink) stuff together. You can also utilize the native PHP syntax to write SQL and that's something that I feel like less and less engineers are doing because we now have all the fancy abstractions - but hey - fundamentals are good :)

I opted for using TALL stack to build out a PaaS. In a couple of days I was able to fully implement mailing, authorization, multiple layouts, fully responsive design and custom middleware for only unauthenticated users. Me and team behind the project will be launching the landing page with the wishlist pretty soon but for now you will have to wait to see it. My point is that it felt good when I was developing with Laravel. A lot of stuff works out of the box and it fights my JS fatigue which has been creeping on me for a long time now. + I want to also one day make bagillion dollars that every laravel engineer is making ;)

Jokes aside, as you can see there's definitely usefulness to PHP and its ecosystem. I would treat the criticism rather scepticlly since a lot of people who use PHP are using it for really old enterprises or they do WordPress for a living which I heard is not that great (but hey maybe I am wrong). If you start using PHP now you will probably be using PHP 8.2 (the core team behind PHP has put in a lot o work to make it great, don't discard their work without trying it first!!!) and a great, highly usable and really stable framework which are just muaaaah (chef's kiss).

Neovim support

Yeah, it's not that great. The LSP sometimes gets really lost and cannot find a method on a Model class and many other little things it just doesn't get. The formatting is not the greatest either BUT I don't want to say too much because I havent looked yet at [this] course(https://laracasts.com/series/neovim-as-a-php-ide) on Laracasts and I heard it's really good so who knows, I might have done something wrong.

End

To sum things up, give PHP a try, you might be surprised how nice it is now especially if you use types (YES PHP HAS TYPE DECLARATIONS GODDAMN IT). I also will write more about Elixir, what I have been up to and why I haven't posted in a while (I moved again). See ya next time, bye!