Know Your PHP Environments
I use Marc Liyanage’s PHP5 distribution on my Mac instead of the version that comes installed with OS X; sooner or later I usually find that there’s some extension that’s either missing or too old for a particular development requirement, and Marc’s distribution is usually a little more up to date and complete.
Recently, however, I installed MAMP to debug some older, PHP4-specific code. It was perfect for my needs, since it’s self-contained and I didn’t need to muck with my base Apache/PHP stack just to spend a couple of hours in PHP4.
I also use Drush, which is an indispensible Drupal command line tool, and I began getting the following error on some sites:
Drush command could not be completed.
It seemed to occur after enabling some new modules, and when I finally got one site back to a state where I could run the drush status command, I noticed that drush was using MAMP’s php.ini file instead of Marc Liyanage’s, which seemed odd; I double checked and verified that the command line PHP executable was using the expected file in /usr/local/php5/lib/php.ini.
Finally, I looked at the contents of the drush shell script itself, and figured out what was happening. There’s an if/else block at the end of the script which checks for MAMP and XAMPP, and uses their PHP executables if found… so even though I wasn’t actually using MAMP any more, drush was finding it and using its PHP executable instead. I commented out the test for MAMP and the ‘command could not be completed’ errors went away.
Tags: DrupalPHPTroubleshootingDrushOS XMAMP
-
var switchTo5x=true;stLight.options({publisher:'dr-8d4fe24c-a8ab-ba90-8086-3791b02244be'});