open core »

Macports and PHP 5.3

I've currently noticed that after updating to PHP 5.3 on macports, the php-cli (command line executable) was giving me some warnings with no sense because I had all the mentioned libraries installed:

PHP Warning:  Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './gd.so' - dlopen(./gd.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mbstring.so' - dlopen(./mbstring.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mcrypt.so' - dlopen(./mcrypt.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mysql.so' - dlopen(./mysql.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mysqli.so' - dlopen(./mysqli.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './pdo_mysql.so' - dlopen(./pdo_mysql.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './zip.so' - dlopen(./zip.so, 9): image not found in Unknown on line 0

This seems to be a very common problem after the update. It occurs because most of the configurations in /opt/local/etc/php.ini are now obsolete with PHP 5.3.

So if your update went well, you should have two samples of php.ini in the mentioned folder. One for production and the other for development. To fix this problem just rename you current php.ini file to something else, and then rename one of the samples to php.ini. Restart apache and voilá. PHP cli is back with no warnings and all the installed libraries available.