The biggest irony is that this question is about a programming platform which is used by an estimated 80% of the web. PHP has lived longer than many of us expected it to and will probably live many more years if something disruptive does not happen in the realm of programming languages. Or has it?
Who Uses PHP?
Firstly, we must accept that PHP is still the best solution for simple informative websites and websites with limited requirements of functionalities & scalability. PHP is hence mostly used by small companies with limited budgets and project of limited size.
Why Should Have PHP Died?
Following are some major reasons why PHP should have died a long time ago, but eventually that did not happen.
-
Not Strictly Typed
As if we had not heard this one before, but, not being strictly typed sometimes becomes critically dangerous for business logic dealing with a lots of numbers.
-
Not As Scalable As Programming Languages Like Python
PHP was not designed for scalability. Simplicity of PHP never let it become scalable enough. It would be madness to develop an software as big as an ERP in PHP.
-
Designed For Web & Only Web?
PHP was designed to be used only for the web and not for desktop applications which is the reason that it could never compete with other programming languages that could be used to develop just about any kind of application.
-
Failure of Framework Like Zend
Configuration over convention is something that just did not work for PHP. Zend could have been a framework that could have taken PHP to another level, and more suitable for business applications, being a framework that allowed very high flexibility. But in order to make it too flexible its developers made it extremely complicated and at the end not many developers used the framework and not many are following its version 2 and 3. If it wasn’t for Magento than the legacy of Zend would have been nearly over.
-
A Framework Like Laravel Only Came As Late As 2011
Before laravel PHP had very less edge over other frameworks for rapid application development and prototyping. Laravel being a really good framework based on “code by convention” did not come until mid 2011. Considering PHP exists since 1995, it could only get a new life after 14 years.
-
Many Good Cometitors Came In PHP’s Lifetime?
PHP has seen many good competitors in its lifetime. First, it was java which was not good enough to criticise the simplicity of PHP. Then Ruby on Rails, which was good for rapid application development but not as easy as PHP. Then came .NET Framework (C# & VB.NET) with its own Windows stack which alone was the reason it could never beat PHP. Then cam Python which was scalable but in many cases slower than PHP. All these programming languages were really good competitors and were according to some were even good enough to kill PHP.
-
Not for Enterprise?
Zend was the last attempt to make PHP suitable for the enterprise an did it fail in this or what? PHP might never be considered for enterprise level software.
Why Is It Still Alive?
-
It was made for the web from the start
As its recursive name suggests PHP (PHP Hypertext Preprocessor) was made for the web from the start and that is the purpose that it serves pretty well. In fact it might be interesting to know that initially its full form was Personal Home Page.
-
Shared Hosting (cPanel)
This might seem like a reason not very much related to the programming language itself. But, it is one of the major reasons for its success. Lets admit it, PHP developers have the options of using the cheapest hosting plans due to shared hosting software like cPanel. This makes PHP ideal for small Software Development Companies and websites of small businesses. Who would buy a VPS or a Dedicated Server for websites so small. Even though there is a really good control panel like Plesk available for hosting ASP.NET applications. But then you also have to consider the cost of Windows stack for software development. On the contrary the PHP stack can be completely free.
-
It Is Damn Cheap
Developing PHP applications can be very cost effective in many cases. Firstly, the development stack (as mentioned in the previous point) is completely free due to things like LAMP, WAMP and XAMPP (my personal favorite). Then PHP developers are usually paid less compared to developers of most of the other programming languages which further decreases the cost of software development.
-
Mostly Open Source
One can find tons of open source libraries for PHP development. And thanks to online open source free directories for PHP libraries like Packagist (for Composer) and GitHub, you can find open source PHP projects for many purposes. This helps in avoiding the reinventing of the wheel and saves a lots of development time (and hence money). Not to mention thanks to Composer, dependency management in PHP is now a piece of cake.
-
Code is Open
PHP code is not compiled to either machine language or any other bytecode or CIL kind of an intermediate language. It is directly interpreted. Which means that you have direct access to all the source code of all the libraries, plugins or packages that you use, regardless of the fact that whether they are proprietary or not. This helps you in customizing any third party code that you are using in your project.
-
Saved By WordPress
Nearly 25% of the web is made of WordPress and WordPress has been made in PHP. WordPress was initially used to just create blogs in PHP. Then people started using it to create entire static websites. And now thanks to a very large library of plugins, WordPress is now used for to create websites for various purposes, for instance WooCommerce plugin is used to create E-Commerce websites.
-
Saved by Laravel
Laravel is the most famous PHP framework at the time of writing this article. It is based on MVC architecture and strongly prefers “convention over configuration“. It works with composer, has its own CLI, and has built in unit testing tools. Laravel has made development in PHP very simple and more organized.
-
Everyone Loves Simplicity
PHP is one of the easiest web-development languages out their. Not being strictly type cast helps a lot in saving time spent in writing some extra code and debugging. Sometimes what variables you will need in a function is not clear in advance and PHP doesn’t expect to be so either. Using Laravel rapid prototyping in PHP has be come a breeze.
-
Who Cares About Scalability From The Start
PHP was not built for scalability. But Who cares about scalability when your project is not large enough for such a concept to even matter. Mark Zuckerberg did not think about it while creating Facebook as a college student. When projects are small enough and budgets are limited PHP can be the best bet for new startups which can later switch to other platforms if they have that much money in future. PHP gets things done in a cost effective manner and hence sometimes is the only option.
So Is It Still In Danger?
Oh yes PHP is in serious danger this time! There are new competitors in the market and the most famous one is the mighty Node.js. But to replace PHP Node.js or other new programming languages (like Google’s very own “Go“), will need to have many factors in their favor which are in favour of PHP right now.
In fact, there is a new article coming very soon about “Why Node.js Has Not Replaced PHP Yet?”.
Then How Long Will It Live?
Well, being more than 2 decades old, it has already outlived expectations of almost everyone who knows about it. But if a better CMS, E-Commerce platform, hosting control panel is create for Node.js then very soon PHP might decline much faster than we think. With the advent of Single Page Applications for the web and mobile apps, it is nearly certain that a JavaScript will be the preferred language for full stack developers for both server side and client side scripting. Hiring a single developer for both server and client side scripting will definitely save money for the corporate, which can already be seen in the case study of PayPal. Predicting when Node.js will replace PHP is very difficult. But just for a thoughtful guess, if things go the way they are already going, PHP should not live any longer than 5 to 10 more years. But. You never know!
Very harsh reality of PHP right now.