I can’t say I was excited to learn PHP, but after the previous maintainer of our library went on to become the new Commissioner of Major League Hacking, it fell on my plate. Growing up (read while in school), PHP was not viewed as the hip and hot language to be writing, but quite the opposite.
My first instinct was to pick an open issue and learn enough to work my way through it. I wound up choosing this issue (shout-out to Ian Littman for helping me out!). In short, our library was not throwing any errors when an API call failed, instead leaving it up to the developer to check the response themselves. Our other libraries raise an exception when the response status code is not 200, so that was my planned fix. We’ll get back to that in a bit, but to cut to the chase, I never thought I’d enjoy it as much as I did. Here are a few things I found to be pretty rad on my first dive.
It only took a few minutes to comprehend basic syntax.
Just about everything is accessed using the object operator: -> . Having written Java in school, I picked up PHP’s object oriented style fairly quickly.
Arrays are just a mapping object.
It has an awesome package manager.
Composer and Packagist are super solid and just work. $ composer init will walk you through setting up a project and even searches for and adds dependencies. Oh, don’t forget the easy to use dependency injection it generates!
Great testing libraries.
PHPUnit and Mockery really sealed the deal for me. Once I got my bearings, they were a true pleasure to work with. Here is how I tested the issue I mentioned earlier. Mockery and PHPUnit allowed me to stub out the actual web request easily.
There are still a ton things I need to learn, but I can safely say that I’m looking forward to working on our PHP library. If there is something you really love about PHP, tweet it to me @eddiezane!