A big problem of PHP is also its main advantage which is its capacity of easily splicing server side code into the page templates which is very good for dynamic pages but very dangerous because someone who doesn’t know what s/he’s doing may make a huge mess since PHP doesn’t enforce MVC architecture.
Moreover, with the rise of frontend frameworks such as Angular/React, the server responsability is reduced to just offer a REST API to the frontend which will render the user interface based upon the data. With this the view logic is completely decoupled from the server leaving it to just handle the Controller and Model, which makes PHP even less interesting since its templating capacity won’t be used.
Now why 80% of websites use it? Simple, because the development and learning is much faster, so it is ideal for basic sites like small online stores and small businesses webpages. So yes in sheer numbers PHP wins because many hosting solutions already have a LAMP stack ready for these cases.
Now if you consider massive scale sites and from big companies (like the Fortune 500) or even technologically advanced stacks such as Google’s you are unlikely find PHP-powered solution among them. Granted, Facebook started with PHP but now their solution has been migrated to a multi-platform paradigm you will find React.js in the frontend and their most critical backend code runs on C/C++ or D (yes, there is such language) also blended with Python and maybe legacy and less relevant parts are still in PHP.
It is not accurateto say that “everyone” says PHP is bad. While PHP has received criticism from some developers, it is important to recognize that a significant number of websites still use it. The popularity of PHP can be attributed to several factors:
- Wide Adoption: PHP has been around for a long time and has gained widespread adoption across the web development community. Many popular content management systems (CMS) like WordPress, Drupal, and Joomla are built using PHP, contributing to its high usage statistics.
- Low Barrier to Entry: PHP has a relatively low learning curve, making it accessible to beginners and enabling them to quickly build dynamic websites. Its syntax is similar to C-style languages, which many developers are already familiar with.
- Extensive Documentation and Community Support: PHP has a vast community of developers who contribute to its documentation, frameworks, libraries, and online forums. This extensive support network makes it easier to find resources, seek help, and share knowledge.
- Versatility: PHP is a versatile language that can be used for a wide range of web development tasks. It supports various frameworks and libraries that facilitate rapid development and offer solutions for common web development challenges.
- Hosting Support: Most web hosting providers support PHP out of the box, making it easy to deploy PHP-based websites. This availability and compatibility contribute to PHP’s continued usage.
It is important to note that while PHP has its strengths and remains widely used, it also has its limitations and drawbacks. Some developers may criticize PHP for historical reasons, concerns about security vulnerabilities in older versions, or personal preferences for other programming languages. However, the significant usage of PHP in the web development landscape suggests that it continues to be a reliable and practical choice for a large number of websites.