Yesterday I needed to quickly apply some changes to a PHP library hosted on GitHub. I haven't used PHP since I switched to a new PC, so there's some setup to do. But for me as a former PHP developer it won't take too long, will it?
This article won't teach you how to install PHP on Windows. It illustrates my experience, the troubles I went through, and suggests improvements to the process.
The requirements: PHP and PHPUnit
Because I should test my code before committing, I need a runtime environment. IntelliJ IDEA (the big brother of PhpStorm) is here already. What's left is PHP and PHPUnit. The library to lay my hands on doesn't require web. No web server, just scripting.
Step 1: Install PHP
Choosing the right version
Visiting php.net, I learn that the latest releases are 5.4.37, 5.6.5 and 5.5.21. Hrm. What to choose? The downloads page http://php.net/downloads.php tells me that the current stable is 5.6.5, so probably that. Just to be sure, I'd like to know a bit more about the compatibility and feature sets of these versions. On the PHP page, including the documentation, I don't find that kind of data. Wikipedia is my friend: http://en.wikipedia.org/wiki/PHP#Release_history so the 5.6 branch it is.There are more choices to be done on http://windows.php.net/download#php-5.6
32 or 64 bit? Thread safe or not? Zip or Debug Pack? Or download source code?
Ah, there's a helping hand on the left "Which version do I choose?"
Since there isn't an easy answer, I go with the rule-out logic to limit the choices.
- IIS? no.
- Apache? no.
- VC9 and VC11? There's only VC11 for PHP 5.6.5, so I'll need to install that.
- Regarding TS vs NTS since I want CLI I'll go with NTS.
- x86 vs x64, don't want experimental, so x86.
Installing it
After extracting the archive, the novice user might be looking for a setup or install exe. I also checked quickly because years passed by since I had last installed this thing. But no luck. So the good old install.txt file needs to be consulted. And by old I mean old. It seems that this file is an accumulated pile of information that grew in all directions. It's almost 2000 lines long. It explains how to handle PHP 4 throughout the file in 26 places. PHP 4 support ended in 2008, 7 years ago. It's a lot to read.Now at this point I wish there was an installer. There are installers. I've used them in the past. But I don't want web server integration. Just a simple scripting environment. That's what PHP is, according to the first sentence of the front page:
PHP is a popular general-purpose scripting language that is especially suited to web development.
And the install instructions clearly advice me not to use an installer:
Warning
There are several all-in-one installers over the Internet, but none of
those are endorsed by PHP.net, as we believe that the manual
installation is the best choice to have your system secure and
optimised.
Secure and optimized... I need a development environment.
After some ini file renaming and environment variable modification and installing VC11 redistributable (2x, took the wrong version on the first attempt) the PHP command would finally respond.Step 2: Installing PHPUnit
There are instructions at https://www.jetbrains.com/idea/help/enabling-phpunit-support.html and at https://phpunit.de/manual/current/en/installation.html and as always there isn't just one way to Rome.
I was successful with the PEAR way in the past, and JetBrains still lists that as the first option. But as of December 2014, PHPUnit stopped supporting it. Dead end.
After some trial and error with the Composer I've downloaded the latest phpunit.phar and told IntelliJ to use it. But tests wouldn't run:
PHP Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methodsAccording to http://stackoverflow.com/questions/22799619/intellij-idea-wont-run-phpunit-4-0-tests/22799620 I can patch my IntelliJ (ugh!) then I rather try an older PHPUnit as written here http://stackoverflow.com/questions/22531584/how-to-setup-phpunit-for-intellij-idea-13-1-on-ubuntu-13-10
Finding that was a bit of a challenge too, since https://phpunit.de/ has no link to older downloads. Here they are: https://phar.phpunit.de/
And finally the library's unit tests would execute in my IDE.
Conclusions
Such installation and configuration procedures are the reason why I hesitate each time before finally replacing my PC, or installing a newer OS.
All in all it took me, a former PHP developer, 3 hours. Too many brain cycles were burned, too much frustration hit the desk. That was more than a flow stopper - it marked the end of the day.
I'm sure that experienced PHP people can't relate. They know exactly how it works, and are done setting up a new machine in no time. And that's the reason for my writing... try to put yourself into the shoes of a noob.
Does it have to be that complicated? Other scripting languages think not.
PHP used to be the easy alternative. Looking at this mess of installation, and putting it in relation to what one expects these days and what the alternatives offer, I have some serious doubts that some beginners even manage to get started.
But then again maybe it's good the way it is. (If you know what I mean. That's a sarcastic comment in case you don't.)
Suggestions
For manual installation, I believe that the install instructions should be cleaned up completely. A new, shortish, simple file, without the burden of all historical facts of how things once were. But that's just applying patches and fixes.
It's time for the PHP Group to provide or promote an official Windows installer. That's what would really fix the situation.