macosunit-testingphpunitzend-server-ce

Trouble with PHPUnit on Zend Server CE - MacOSX


I've installed Zend Server CE on my MacOS Lion, and everything is running smooth except from PHPUnit.

My installation of PHPUnit was made from the PERL that comes with Zend Server CE.

Here is the output from when I run phpunit through the console:

Failed loading ”/usr/local/zend/lib/php_extensions/xdebug.so”:      dlopen(”/usr/local/zend/lib/php_extensions/xdebug.so”, 9): image not found
PHP Warning:  PHP Startup: Unable to load dynamic library     '/usr/local/zend/lib/php_extensions/mcrypt.so' -     dlopen(/usr/local/zend/lib/php_extensions/mcrypt.so, 9): Library not loaded:     /usr/lib/libltdl.3.dylib
  Referenced from: /usr/local/zend/lib/php_extensions/mcrypt.so
  Reason: image not found in Unknown on line 0
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0
PHP Fatal error:  Call to undefined method PHP_CodeCoverage_Filter::getInstance() in     /usr/local/bin/phpunit on line 39
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/phpunit:0

Does anybody know what the problem or problems could be?

Thanks and regards!


Solution

  • Ok, this is my first answer. So go easy on me.

    Tonight I had the very same issues with Zend Server CE on OSX Lion. In order to solve them, you'll have to install xcode as the unix development tools are required.

    Let's get started, you have two issues: xdebug.so and libltdl.3.dylib

    First xdebug.so is not found, to install it you should run the following from the command line:

    sudo su -
    

    It will ask you for you password (if you don't have one just press the enter key). Then:

    export CFLAGS="-arch i386 $CFLAGS"
    export CCFLAGS="-arch i386 $CCFLAGS"
    export CXXFLAGS="-arch i386 $CXXFLAGS"
    export LDFLAGS="-arch i386 $LDFLAGS"
    /usr/local/zend/bin/pear config-set php_ini /usr/local/zend/etc/php.ini
    /usr/local/zend/bin/pecl install xdebug
    

    The first four lines, force the compiler to generate a 32 bit binary, as Zend Server is a 32 bit binary and OSX Lion is a 64 bit operating system.

    Alright, now you should have xdebug.so installed on */usr/local/zend/lib/php_extensions*, just make sure that your /usr/local/zend/etc/php.ini file loads xdebug with the following line after all other extensions and before the [zend] section:

    zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
    

    Here's the fragment from my php.ini:

    ...
    ;extension=odbc.so
    ;extension=imagick.so
    zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
    
    [zend]
    zend_extension=/usr/local/zend/lib/ZendExtensionManager.so
    ...
    

    If it doesn't please add it manually, then check if your php.ini file contains the following line and delete it as xdebug must me loaded as a Zend extension.

    extension=xdebug.so
    

    Second, as soon as you install xcode, libltdl.dylib will be available in /usr/lib, so you can create a symbolic link to it with the following command:

    sudo ln -s /usr/lib/libltdl.dylib /usr/lib/libltdl.3.dylib
    

    Next time you run phpunit everything should go smoothly (haven't tested any mcrypt functions though).