-
Intro
Around 30 years ago, Rasmus Lerdorf was trying to build a templating engine to allow for easier website building in C. Its purpose was to generate with more ease the HTML pages on the server side. The name of the engine was PHP, Personal Home Page.
Considering the context back then, with the web being in its infancy, but showing a lot of exciting potential, the need for a framework to build websites easier is obvious.
A few years later, PHP got a template engine (Smarty). Yes, the template engine got a template engine.
Fast forward 10 years, a new object model was created in order to fix previous models.
Even the name changed, PHP was now "PHP: Hypertext Preprocessor", a recursive acronym.
I think it’s safe to say that the original plan changed quite a bit down the line.
My story with PHP
When I was in high school I built my first website for a school project - it was the periodic table of elements. I was very excited about building things that could be part of the Internet! I wanted to make things more dynamic. Before that point I was just copy/pasting JS code from various websites to make things seem more dynamic. Back then, there weren't a lot of resources to learn JavaScript from.
My story with PHP started in my first year of college.
A friend who was a “Webmaster” suggested that I should try PHP and MySQL as they are easy to learn.
I wish I could say that I got a job right away, but things in the early 2000’s weren’t that great, there weren’t many jobs for junior programmers.
Before I landed my first job, I was at an interview at a company and told them I was excited about PHP, to which the manager laughed and told me I should learn a real programming language, like FoxPro! At that time, PHP was very much regarded as a toy language.
Not long after, I finally landed my first job as a programmer. I was so excited and terrified of how much I didn’t know.
It turns out that PHP was a great option at the time, there were a lot of career opportunities, it was its golden age. Frameworks and platforms were popping all around. Smarty, CakePHP, Symfony, Wordpress, Magento and many many others.
I had the opportunity to work for all kinds of clients, some barely had any customers, others had millions of users.
It was a cool and trendy language used by many companies, including Yahoo! and Facebook. Even Google was using it for the merchandise shop.
I’ve used it on and off for 16 years and I would enjoying using it again if the right opportunity appears.
The downfall
On one not so special day in 2017, while working as a Magento 2 developer, someone told me that it wasn’t as easy as it used to be to find programmers, young programmers don’t consider PHP as cool. This was a shock to me as the language was still very exciting, there were plenty of jobs and new and interesting features appearing all the time.
But yes, that was the beginning of the downfall of PHP, for reasons that are not very clear to me.
Languages like Node.js began to really take off, that became the “cool” kid on the block. People were complaining about PHP’s dynamic nature and using Node.js as an alternative.
Last year someone was joking “at least we are not doing PHP”, I wasn’t amused, we are doing Erlang. If you wonder why there are still more PHP projects then Erlang, you should start learning Erlang, I'm sure you’re not going to ask that question again when you’ll know it well enough.
This year at FOSDEM, I had a discussion with some other dev about PHP. He was joking about how bad it was, I asked him what made it so bad, and it turns out that he never worked with it, but he had some very good examples of major issues, most of which were fixed with PHP 5.3, which was released in 2009, 16 years ago.
Speaking of FOSDEM, the first time I went to the conference, more than a decade ago, PHP had an amphitheater, a huge place and lots of people. After a few years it moved to a big room, still plenty of space and plenty of people. Last time PHP had a room there was in 2019, a small room for only about 50 people.
While PHP is far from extinct, it’s a shame that it’s losing its popularity after it has become so advanced. It’s a good example of technology that did nothing wrong, yet started to be phased out of use.
Epilogue
PHP has risen, taken over the world, but now, it seems like it has lost its shine. The market is changing, other languages have appeared, with new frameworks and with different approaches to programming.
While many people complain about its limitations, it’s been used in systems from small blogs to tech giants, from small shopping carts to mission critical infrastructure.
It may shine again, or it may just become a language in maintenance. Whatever the future will bring, I want to wish it a happy birthday, and thank you for the ride! It's been a great journey!
-
I’ve been working with Magento for a long time and I can say that the platform changed a lot over time and I would like to share my personal thoughts on it.
How Magento 2 learned from the past to make some brand-new mistakes
I had my first encounter with Magento in 2011 and, back then, all I knew about it was that it was based on Zend Framework and that it was doing e-commerce (obviously).
I was coming from the Symfony framework world, with a lot of documentation, a great community and a rock-solid implementation. This was still Symfony 1, Symfony 2 was just coming out.
By comparison, Magento had next to no documentation, barely any community and the implementation had a plethora of bugs. In my first few days on the job I was seeing a lot of people debugging deep in the Core, I was just perplexed, I almost never needed to debug Symfony, let alone actually find bugs.
Some may argue that Symfony is a framework and Magento is a platform and the argument is as solid as a guinea pig.
The reason for this situation was simple: they didn’t expect the platform to have so much success; but it did and the reason was simple – it was pretty much the only platform in the PHP world that was built with modularity in mind at that time, period! There were other platforms, but definitely not as versatile, fully featured and modular as Magento.
Moving forward, they’ve spent a lot of time and effort in building ample documentation for Magento1, focused on quality, rock-solid stability, all paired with exceptional support for enterprise partners!
Psych! No, they did not! The documentation for M1 was always sparse and of very poor quality. Basically, the best resource was Ben Marks’ “Fundamentals of Magento Development” course, a book (about which and not entitled to an opinion, since I didn’t read it), some blog posts from individuals or companies that worked with the platform and a lot of StackOverflow questions and answers. All this was paired with exceptionally bad support for enterprise users, extremely slow and low quality solutions and, to top it off, plenty of Core bugs. It wasn’t unusual to find non-standard, half-baked implementations and bugs in the Core. But the Core was simple enough that, with Xdebug and a lot of patience, everything was more or less fixable.
Fixes coming from their support team were close to a myth. If you didn’t want to fix a bug, or just didn’t feel like working, you could open a ticket and in most cases it took days or even weeks to get a proper response. By that time you would have usually fixed it already and (in some cases) even sent the fix to their support so they can also include it in the Core.
And along comes Magento 2
With the burden of the popularity-driven growth of Magento 1, Magento 2 came to the rescue.
It took a long time for Magento 2 to be ready, and I think that is more of a story in itself, but some actions were taken to prevent some of the issues that the first version had.
Let’s look on some of the platform issues:
- classes could only be extended by overwriting;
- the frontend was based on the Prototype framework.
There were many other changes but I think these were among the most important ones.
And now let’s see how Magento 2 managed to fix all these issues
It is a good practice to start with something nice, so I will start with the documentation, Magento2 had documentation from the start and it was both useful and well made!
Regarding the classes overwrite, there were implemented two approaches:
- implementing dependency injection (from Symfony)
- implementing plugins using interceptor pattern.
Dependency injection really helped with the ability to substitute classes and functionality, and the plugins helped a lot with a non-invasive way of extending the functionality. Before plugins, only observers were able to modify data in a non-invasive way, and the big problem was that (in many cases) there just weren’t observers everywhere you needed them to be.
Unfortunately, this created a lot of overhead. Maybe in M1 you could just put a breakpoint and look in the stacktrace to see what methods are changing what, but now… it is just a lot more complex, each method has an interceptor class that triggers the plugin mechanism. Each plugin can be triggered before, after or around the method, the around method can prevent the actual method from getting called. In short, it is a lot more code with a lot more methods and a lot more code to follow. When it is working is a lot more elegant, but when it doesn’t it is a lot worse to debug.
In a dramatic twist, many of the classes were not implemented properly in the Core. You see, when Magento2 was released, a lot of compromises had to be made, and some of the Core modules were just “made to work” in the new framework. Later when everyone was expecting the cleanup to be made… it wasn’t, the reason is simple, why fix the Core when you can break compatibility with the modules already created?
This issue even made Magento Core developers suggest that you should follow the guidelines, not use the Core as an example: do what we say, not what we do.
Frontend was fixed even better! You may ask yourself what is that “prototype” library and why would anyone in their right mind choose it? It made a lot of sense back then, when Magento1 was created and there were several popular js libraries, mainly: jQuery, Prototype and MooTools. There were a lot more than these 3, but these were the popular ones. There was a war between jQuery and Prototype, just like there is now between React, Angular and Vue. The first had a new approach with almost a new language, while the second was aiming at extending the browser capabilities in a more discrete fashion. We now know who won, but back then it wasn’t obvious. As a small note, I was also a fan of Prototype back then.
The Magento 2 team realized over time that it was a mistake and, to fix it, they promised to make something more flexible. The new more flexible solution didn’t involve the Prototype library, but instead included: jQuery, Knockout.js, and Require.js just at the top level, without taking dependencies into consideration.
The idea was to separate the frontend and the backend, to have the ability to make completely new frontend APPs. And, as before, this was never properly finished and now there is a highly complicated system, partially separated, partially single page App and partially… multi page, implemented in a variety of styles. And this is only on the store front, the store backend has a slightly different, more complex system of xml, phtml, html and js files.
As a backend developer I can truly say that it is a lot harder to debug (or just to understand how the frontend part works) now than before.The XML part of generating grids is probably the hardest part, it is extremely difficult to debug anything in it and, if you mess something up, you get no warnings at all, you have to find the class that is building the grid and see if an exception is triggered there, but that is not an obvious solution at all…
And, of course, the entire thing is a lot slower because of all these “new engineering features”. When all the code is generated and the links to static resources and everything set to production mode, it isn’t slow; it isn’t exactly fast, but it isn’t terribly slow either. But when you don’t have cache, and didn’t deploy the static resources, and you are in developer mode, it is just awfully slow, it can take a few minutes to load a simple product page! It is just ridiculous if you ask me, it isn’t an operating system, or a video game, it is a shopping cart, why in the world would it take 5 minutes to display a page, even without a lot of new modules.
Keep in mind that Magento 2 didn’t come with a lot of new features, most of the functionality was in M1, only more “engineered”, so those 5 minutes of code generation and linking and whatever magic is going on in there aren’t adding a lot of new features, just a lot of refactoring of the old system.
The Magento Cloud
Magento offered a Cloud, I don’t know if they are anymore and I don’t care, nobody really cares about it anymore, mostly because it wasn’t what everybody wanted.
People want simple things, you have an app, you push it to the clouds and money starts raining down. That should be it, less things to worry about.
Demandware, who doesn’t have a nice open source core, is doing something exactly like this: you don’t have the same amount of control, but you don’t take care of your website, the gods in the clouds do! The developer only develops, doesn’t need to care about what magic operations are doing, because he is not ops, he is dev!
The Magento Commerce Cloud was aimed to do that, just push this monster in the cloud and some very smart ops will scale it for you! But it wasn’t like this, it was never easy, nor fast. And, on top of that, other hosting providers started making hosting solutions for Magento that were better at scaling then the official one, which is just ridiculous.
A positive note to end on
There is an interesting core underneath it all.There are plenty of very smart features that make the platform so popular. Now you also have tests, so you can even do TDD.
Even with all this (over) engineering challenges, there are still plenty of passionate developers out there that are able and willing to overcome them.
There are also a lot of tools developed by the community to overcome some of the shortcomings, like generate the huge amount of files required for a model, or MSP_DevTools to help with debugging the frontend, or n98-magerun2 to help with crons and lots and lots more.
And lastly, there are still a lot of very brilliant and passionate developers out there that are willing to figure out a way to develop, scale and make sales for one more day!
-
Ah, the holiday spirit.
Inspired by a post in Perl Advent, I decided that it would be nice to see an example done with PHP and Go. Please note that this blog is heavily inspired by the post mentioned above.
Let’s say you want to wish upon others happy holiday using the speed of Go, but you are using PHP, what is there to be done?
This is a great time in the PHP world to do something like this, as the newly released PHP 7.4 comes with “Foreign Function Interface” (FFI for short).
Equipped with this new power, I installed PHP 7.4 and got to work.
Let’s start with the super incredible Go greeting part, let’s create a file “greeting.go”:
1package main 2 3import ( 4 "fmt" 5) 6 7func main() { 8 WishMerryChristmas(); 9} 10 11func WishMerryChristmas() { 12 fmt.Println("We wish you a Merry Christmas!"); 13}Now let’s run it with:
1$ go run greeting.goIt should display:
We wish you a Merry Christmas!Great stuff so far! Now this is nice and fast and everything, but it needs to be a service, let’s see how that would look like:
1package main 2 3import ( 4 "C" 5 "fmt" 6) 7 8func main() {} 9 10//export WishMerryChristmas 11func WishMerryChristmas() { 12 fmt.Println("We wish you a Merry Christmas!") 13}As you can see, there are several differences:
- we also imported “C”,
- we removed the function call from main()
- we added a comment to export the function.
To compile the code, run:
1$ go build -o greeting.so -buildmode=c-sharedNote that this should be run each time the Go file is modified.
The output should be two files: “greeting.so” and “greeting.h”.
The header file “greeting.h” file contains the types and functions definition. If you come from C world you are probably already familiar with this type of files. Normally, all we need to do now is to import the header file using FFI and use the function!
For this I’ve created a file titled “greeting.php”:
1<?php 2 3$ffi = FFI::load("greeting.h"); 4$ffi->WishMerryChristmas();Sure looks simple enough, you just have to run it with:
1$ php greeting.php 2PHP Fatal error: Uncaught FFI\ParserException: undefined C type '__SIZE_TYPE__' at line 43 in /home/claudiu/php-go/greeting.php:3 3Stack trace: 4#0 /home/claudiu/php-go/greeting.php(3): FFI::load() 5#1 {main} 6 7Next FFI\Exception: Failed loading 'greeting.h' in /home/claudiu/php-go/greeting.php:3 8Stack trace: 9#0 /home/claudiu/php-go/greeting.php(3): FFI::load() 10#1 {main} 11 thrown in /home/claudiu/php-go/greeting.php on line 3Not exactly the greeting that I was hoping for…
After some digging, I found this one on the manual page:
C preprocessor directives are not supported, i.e. #include, #define and CPP macros do not work.Because of this, we unfortunately can’t really use the header file, or at least I don’t know how.
On the bright side, we can use FFI::cdef() which allows for function definition specification. If I lost you on the way, what I’m trying to do is just tell PHP which are the function definitions that it can use from “greeting.so”.
The new code will become:
1<?php 2$ffi = FFI::cdef(" 3void WishMerryChristmas(); 4", __DIR__ . "/greeting.so"); 5 6$ffi->WishMerryChristmas();And if we run it:
1$ php greeting.php 2We wish you a Merry Christmas!We are making great progress, the service is doing a great job!
Adding an int parameter
The greeting is nice and fast and all but it would be nice to be able to specify how many times to run it.
To achieve this, I’m modifying the previous example method to specify how many times to display the greeting in the file greeting.go:
1//export WishMerryChristmas 2func WishMerryChristmas(number int) { 3 for i := 0; i < number; i++ { 4 fmt.Println("We wish you a Merry Christmas!"); 5 } 6}Run the compilation as before and everything should be fine.
In the PHP script we need to modify the function definition. To see what we should use we can take a hint from the “greeting.h” file. The new function definition in my file is:
1extern void WishMerryChristmas(GoInt p0);“GoInt”? What magic is that? Well, if we look in the file, there are the following definitions:
1... 2typedef long long GoInt64; 3... 4typedef GoInt64 GoInt; 5...With this in mind, we can change the PHP file to:
1<?php 2$ffi = FFI::cdef(" 3void WishMerryChristmas(long); 4", __DIR__ . "/greeting.so"); 5 6$ffi->WishMerryChristmas(3);Run it and you should see:
1$ php greeting.php 2We wish you a Merry Christmas! 3We wish you a Merry Christmas! 4We wish you a Merry Christmas!Ah, it’s beginning to feel a lot like Christmas!
Adding a string parameter
Displaying a greeting multiple times is quite nice, but it would be nicer to add a name to it.
The new greeting function in go will be:
1//export WishMerryChristmas 2func WishMerryChristmas(name string, number int) { 3 for i := 0; i < number; i++ { 4 fmt.Printf("We wish you a Merry Christmas, %s!\n", name); 5 } 6}Don’t forget to compile and let’s get to the interesting part.
Looking into the “greeting.h” file, the new function definition is:
1extern void WishMerryChristmas(GoString p0, GoInt p1);We already got GoInt, but GoString it is a bit trickier. After several substitutions I was able to see that the structure is:
1typedef struct { char* p; long n } GoString;It is essentially a pointer to a list of characters and a dimension.
This means that, in the PHP file, the new definition is going to be:
1$ffi = FFI::cdef(" 2typedef struct { char* p; long n } GoString; 3typedef long GoInt; 4void WishMerryChristmas(GoString p0, GoInt p1); 5", __DIR__ . "/greeting.so");p0 and p1 are optional, but I’ve added them for a closer resemblance to the header file. On the same note, GoInt is basically a long, but I left the type there for the same reason.
Building a GoString was a bit of a challenge. The main reason is that I didn’t find a way to create a “char *” and initialize it. My alternative was to create an array of “char” and cast it, like this:
1$name = "reader"; 2$strChar = str_split($name); 3 4$c = FFI::new('char[' . count($strChar) . ']'); 5foreach ($strChar as $i => $char) { 6 $c[$i] = $char; 7} 8 9$goStr = $ffi->new("GoString"); 10$goStr->p = FFI::cast(FFI::type('char *'), $c); 11$goStr->n = count($strChar); 12 13$ffi->WishMerryChristmas($goStr, 2);And let’s try it out:
1$ php greeting.php 2We wish you a Merry Christmas, reader! 3We wish you a Merry Christmas, reader!Success!
At this point I would like to move the GoString creation in a new function, just for the sake of code clean-up.
And the new code is:
1$name = "reader"; 2 3$goStr = stringToGoString($ffi->new("GoString"), $name); 4 5$ffi->WishMerryChristmas($goStr, 2); 6 7function stringToGoString($goStr, $name) { 8 $strChar = str_split($name); 9 10 $c = FFI::new('char[' . count($strChar) . ']'); 11 foreach ($strChar as $i => $char) { 12 $c[$i] = $char; 13 } 14 15 $goStr->p = FFI::cast(FFI::type('char *'), $c); 16 $goStr->n = count($strChar); 17 18 return $goStr; 19}And let’s try it:
1$ php greeting.php 2We wish you a Merry Christmas, ��! 3We wish you a Merry Christmas, ��!That’s not right… it seems like it’s displaying some junk memory. But why?
Looking into the documentation for FFI::new I’ve seen a second parameter “bool $owned = TRUE”.
Whether to create owned (i.e. managed) or unmanaged data. Managed data lives together with the returned FFI\CData object, and is released when the last reference to that object is released by regular PHP reference counting or GC. Unmanaged data should be released by calling FFI::free(), when no longer needed.This means that, when the function was returned, the GC is clearing the memory for the string. This is very likely a bug, but there is a very simple fix, just modify the char array creation to “false”:
1$c = FFI::new('char[' . count($strChar) . ']', false);Let’s try it again:
1$ php greeting.php 2We wish you a Merry Christmas, reader! 3We wish you a Merry Christmas, reader!And it’s working!
Conclusion
Maybe it’s not as easy as importing a header file when trying to run Go libraries from PHP, but with a little patience it is certainly possible! A big advantage to this is that a library built in Go, or other programming languages that allow it, can be used by a language like PHP without the need to reimplement the logic!
And, on this last positive remark, I would like to wish you happy holidays!
-
I have recently passed the Zend Certified Engineer 2017, certification offered by Rogue Wave.
While experience is the most important thing for a certification, books are the best way to expand your knowledge, in my opinion.
Since a certification is something very specific, there aren’t a lot of books.
Before we begin, keep in mind that the most exhaustive resource for learning PHP is the manual, always take a look on all the classes and functions available.
Zend Certified Engineer Exam Study Guide $20
I’ve bought this book just so I can review it and earn my right to have an opinion about it.
The study guide was introduced with the certification for PHP 5.3 and it was a free resource. The quality of the book has updated continually, but never by a lot and at some point it was no longer a free resource.
Over time I kept hoping that it will become better and better, but it didn’t. It’s a short book with a big font and lots and lots of misspellings and errors.
The only good part about it is that it has several questions for each chapter, other then that it’s not a very good resources and it’s not worth the $20, probably about $5 would be closer to a fair price since with every version they just update it a bit and adding the new features of the language. The questions don’t even seem to change a lot over time.
So if it’s the only book you are going to buy, go for the next one.
PHP 7 Zend Certification Study Guide – Andrew Beak – Apress 2017 – $19.99
The book is exploring all the sections for the certification in more depth, it has over 300 pages.
It feels more like a programming book and less like a guilde. The quality of the book is way better than the official guide, but that’s not hard at all considering that the guide set such a low bar.
There are also questions on all the chapters which is a good way to practice your knowledge in an exam format. The questions just feel a bit more soft than the guide, the exam itself has a lot of very tricky questions.
Of course this book is not exhaustive, you can’t really cover all the subjects in depth in a single book, and even if it did, then you would probably not have time to read it anyway.
If you are going to buy a single book, I would recommend this one, since it’s an actual book, not a very high level (and low quality) guide.
Zend PHP 5 Certification Study Guide, Third Edition – php[architect] – $22
If you think that I’ve got the version wrong, well, what can I say? you are right!
I wanted to add this book here because for me it was the best Study Guide. Over the years there were various study guides but this one I liked the most.
For the PHP 5 certification there wasn’t an official certification from Zend, only the first edition of this book. It was just a nice programming book to read. Sometimes, when I want to remember something that I haven’t used a lot, or at all, I will read the chapter in this book.
When I took the PHP 5.5 certification, (because I just had to collect them all) I was happy to find out that there is a new version of the book.
It’s basically the same book but updated to cover the new certification. It may be that I like Davey Shafik’s style of writing.
The book feels a bit more dense in terms of information, for me it just feels more like a study guide then the previous book.
However this book does not have questions and is no longer up to date.
If you have the time you can give it a read anyway, I think it is a good general PHP book.
Conclusion
Not a lot of books for this certification, but if I had to pick only one, it would be the “PHP 7 Zend Certification Study Guide” from Apress.
Unfortunately there isn’t a lot of competition, because the “Zend PHP 5 Certification Study Guide, Third Edition” from PHP Arch is no longer up to date and the official guide just isn’t worth the $20 price tag.
If your boss will buy the books, I say go all in! After all, the cost is: $20 + $19.99 + $22 = $61.99! Not bad for three programming books!
-
Yes, PHP is probably the most popular programming language on the server side for the web at the moment. And it’s probably going to be for a long while…
It’s probably the best!
That’s not really it, just read on…
Why is it so easy to learn?
First of all, it’s the syntax. It’s not the best syntax out there, the reason is actually that it’s the most popular! I knew most of the syntax before I even looked at a “hello world” example, why? I’ve studied C in school, and people coming from Java had the same feeling.
Let’s see a few programming languages that are using this syntax: Java, C#, JavaScript, Perl, Go, PHP and, of course, C and C++, and between them you have most of the market and platforms.
Unlike (most) other languages listed above, it’s a lot easier to get started! You don’t have to create a main function, a class or anything else to get started, you just get down to it!
The good part is that you can make it as complex as you want (or need) to, these days there are Java-like classes and interfaces, horizontal inheritance with traits, functional programming with closures and anonymous functions, generators and, if you really are a hipster, even goto.
But PHP doesn’t sound so bad…
Now, there is an important detail that must be mentioned, PHP didn’t become popular because of the features mentioned above, but the features came to it because of its popularity, even “goto”. I don’t know why somebody would add goto to a language more than 10 years after its creation but that’s none of my business, nor is it important for the subject at hand.
The language became really popular with versions 3 and 4. By the time a decent OOP model is introduced, it had already gained a lot of popularity! Now, especially more so since PHP 7 is looking a whole lot more like a decent programming language, but 10 years ago it wasn’t the same story.
But node.js will probably surpass it!
Right… remember Ruby? Python? And others…
If you think about PHP, it has a major advantage and disadvantage, is very much as stateless as it can be.
With PHP you feel like it doesn’t know anything about the world, you have to bootstrap everything all the time. The advantage is that if you have a memory leak, most of the time, it’s ok. The current user will finish and everything will get cleared and nobody will have to care. And PHP had a lot of memory leaks when it started to became very popular and nobody seemed to mind.
When people started making cron jobs and other long running processes, this becomes a big issue and the need for features like explicit garbage collection became a must. That was added with version 5.3, which was released in 2009.
Normally, continuous running should not be a disadvantage, so the moral of this story is that it’s not necessarily an advantage either.
Nobody is going to build the next Google on it, but how about some blogs? Or even better, some shopping carts?
It just doesn’t have what it takes for something like the Google search engine and that’s ok because it was just not designed for that.
Another example for “not necessarily the best will win” is that WordPress is the most popular blogging platform.
Even more, people are using WordPress for all kind of weird things, basically you can do anything with it! And you should not blame the people using it, it’s not like you look what’s in your microwave when you buy it, you just want to have a warm meal. People forcing the limit of WordPress are doing the same, they can do what they need, so there is no good reason not to.
Should I ever use it?
Let’s take a couple of positive examples: Yahoo! and Facebook.
Yahoo! has been using it for a very long time on some of their products and in combination with other programming languages.Facebook has been using it since the beginning because it is so easy to learn. They have been pushing the limit of the language in several occasions with: HipHop for PHP and more recently Hack, which was a very important motivational drive and a big influence for PHP 7.
Why all that trouble for a language? Because it’s just so easy to learn and use!
Usually, it’s a lot more important to release “now” then to have something “perfect” later, especially on the world wide web.
There is a very good reason why a language that is definitely not “the best”, but it is easy to learn is so popular online, while a programming language like C, which is way harder to learn, is more popular offline than online.
In other words, while definitely not being the best, PHP is most of the time just good enough.