Sunday, November 25, 2007

PHP Eccentricity

I never have used the PHP CLI executable (php.exe); and perhaps this is why I never came across this earlier. It was while trying to extract PEAR through the provided go-pear.bat file (located in root folder of your PHP installation), that I became irritatingly familiar to it.

Here is what was spewed out
This application has failed to start because php_mbstring.dll was not found. Re-installing the application may fix this problem.

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php5\ext\php_exif.
dll' - The specified module could not be found.

And here are some solutions that did not work
  • Moving php_mbstring.dll to root folder of PHP: PHP executable started crashing, each and every time.
  • Commenting out php_mbstring.dll from php.ini: Even worse, as its provided functions are required by other libraries eg. exif library
  • Changing the php root folder (and the associated settings in php.ini, and apache) : To no avail
  • Re-installing the files: No change.

I could not trace out where the problem was. I could've been the CLI, or the PEAR package, or the php_exif.ddl or php_mbstring.dll.
In the end, I found something related, and the Online PHP Reference seemed to confirm it...
"Windows users must enable both the php_mbstring.dll and php_exif.dll DLL's in php.ini. The php_mbstring.dll DLL must be loaded before the php_exif.dll DLL so adjust your php.ini accordingly."


The easy solution: Open your php.ini, and paste the line that loads the php_mbstring.dll over the line for php_exif.dll.
Alternatively, you can disable both the mbstring and exif extensions, but that makes little sense. You wouldn't enable them if you didn't need them in the first place.