The reasons that lead people to hate something are completely irrational, like any feeling, but today, we live in a society where for some strange reason we have to be part of the team of something and being part of that team often leads us to love what the team wants and hate what the team hates. We see it in everything, today very accentuated in soccer or politics, but yes, we developers have also opted for this trend, front end hates back end and vice versa and programming languages were not going to get rid of this trend, they also have haters.
PHP is one of those languages that suffers the hatred of many developers, and eye, I'm not saying that you have to like PHP, but as much as hate it. I have heard from many colleagues this phrase: "Ugh, I hate PHP! and the best of all is that many have not even touched it or very above, do not know its features and especially its utilities and benefits in certain contexts.
Developers can not afford to hate a technology, nor do we have to like all of them, but it is good to know that they exist and what are their particularities in order to know if it is good to opt for one or another in a particular project. In the case of PHP, its qualities and features make it useful in a lot of situations related to web development.
A bit of history
PHP was born in 1994, curiously as a personal project of Rasmus Lerdorf, hence the acronym PHP comes from Personal Home Page Tools, it was written in C and was a set of scripts that served to track visits to your online curriculum, as you can imagine, at that time, Google Analytics was not even thought. Gradually it was adding features such as the ability to connect to databases and many more things. But it was not until PHP 3 where we find that the language evolves to something that today we can identify with modern PHP.
One of the main qualities of PHP in the late 90's was its ability to create dynamic web pages, giving life to a web that at that time was quite static and making much more accessible to developers the ability to, for example, register users or display content conditionally.
PHP startup madness
Probably here comes part of the displeasure of much of the community with the language and is that in the early 2000s the concept of "best practices" was not as widespread as today and not being PHP a typed language and being able to intertwine with HTML code inline, reading a PHP project in some cases could be crazy, but to be honest, that does not happen today for example with React and yet people love it. I have seen React projects that you can't get your hands on, class components mixed with functional ones, an incomprehensible folder structure, components lost here and there, I have even seen a React component with more than 5000 lines of code and watch out, that in 2022.
Therefore, whether a project developed with a particular technology is a chaos, does not depend on the technology, but on the developer or developers and their ability to follow good common practices.
PHP Security
Another of the reasons given for "hating" PHP has often been security and while it is true that PHP had many shortcomings in that regard, I get the feeling that people still have that perception of PHP 4, in fact, PHP 5 already arises correcting much of the shortcomings in language security and today we are already in version 8 of PHP, security today is not a major drawback than in any other programming language.
PHP speed
This is another handicap of PHP with respect to compiled languages and it must be admitted that it is much slower than languages like Java or C since these languages are compiled, but PHP version 8 incorporates JIT which is grosso modo a real time compiler, undoubtedly the biggest improvement that brings this version making it 5 times faster with respect to version 7.
It is obvious that it is still slower than compiled languages, but does this mean that it is slow, not at all, in fact you will find few occasions where the speed of PHP 8 is a reasonable handicap to discard it when including it in a project, especially the type of project for which PHP was conceived which is the web.
PHP Types
The last reason to hate PHP that we will discuss today is types. PHP is not a strongly typed language, in fact, it is not until version 7 where we can start using PHP types to protect our data. This is really a matter of personal taste, there are people who love strongly typed languages, it is not my case, in fact I find them a pain in the ass. For me the ideal is really that you can type or not at your convenience, it is the same with Javascript, it is not a typed language and to solve it, Microsoft invented Typescript, but even so, Typescript does not force you to type everything in a strict way. And the same thing happens with PHP, you can type it or not according to your needs and that for me is perfect because there are situations where, for example, the data received by a variable may be a string or an integer or you may want to change the type of data contained in a variable on the fly or a function may return several types of data.
In these cases, strongly typed languages force you to write a lot more code and can give you a lot of headaches when compiling depending on the type of project. Not that a non-typed language can't give you headaches when you suddenly see something fail and it's because a variable doesn't have the expected type, but if you are a clean developer who knows what he is doing and uses good programming practices, just as compiling in a strongly typed language won't give you headaches, neither will programming in a non-typed language and for me the big advantage is that you can type or not according to your needs.
Evolution and advantages of PHP
PHP has evolved a lot, perhaps of the languages that have done more since its birth, today you will hardly miss features of many programming languages, for example, you can create interfaces, complex data types, manage them at your convenience and it is fast.
But above all it is a programming language designed for the web and that makes it the best in this aspect to handle the backend of a web project. In fact, as a front end I really miss that the entry points of the packers can not be, plugins aside, files with .php extension, since the Server Side Rendering would not be so complicated in many occasions.
We have very powerful frameworks such as Laravel that make life much easier when creating a web project in PHP and now even has the possibility of integrating Vite and Vue in the project in a very efficient and easy way.
But, above all, building a PHP project is cheap, most hostings you can buy have integrated Apache and PHP for ridiculous prices, in fact in most of my personal projects I use PHP to create REST APIs to consume from the front end.
Conclusion, if you have never used PHP or only used it very much, try it and you will see that it is a technology that can be useful for you. If you used it years ago, give it another chance, but, above all, if you are going to use PHP, don't use Wordpress, I hate Wordpress. 😝