Install PHPUnit using PEAR in XAMPP

Source Code Icon

In order to install PHPUnit using XAMPP you have to issue the following commands:

sudo ./pear channel-update pear.php.net
sudo ./pear channel-discover pear.phpunit.de
sudo ./pear channel-discover components.ez.no
sudo ./pear channel-discover pear.symfony-project.com
sudo ./pear install --alldeps phpunit/PHPUnit

First, you (might have to) update PEAR with the changed protocols used by channel pear.php.net. Next, add three channels to satisfy all dependency requirements for PHPUnit. Finally, install PHPUnit using the –alldeps options to automatically discover and install any dependencies. As you might have guessed the commands above originate from a Linux shell (sudo). Therefore, I you plan to use these commands under Windows simply replace “sudo ./pear” with “pear.bat” and you are ready to go. Additionally, depending on your Linux setup and the location of XAMPP you also might not need to be a super user (sudo) to issue these commands.

Comments

2 responses to “Install PHPUnit using PEAR in XAMPP”

  1. Alvaro M. Avatar
    Alvaro M.

    I think it works just for PHP on a Linux (Ubuntu in my case) in the /usr/lib/php, not for XAMPP opt/lampp

    eg:
    1) DbTest::testConnection
    CDbException: CDbConnection failed to open the DB connection: could not find driver

    /opt/lampp/yii/framework/db/CDbConnection.php:382
    /opt/lampp/yii/framework/db/CDbConnection.php:331
    /opt/lampp/yii/framework/db/CDbConnection.php:309
    /opt/lampp/yii/framework/base/CModule.php:388
    /opt/lampp/yii/framework/base/CModule.php:104
    /opt/lampp/htdocs/trackstar/protected/tests/unit/DbTest.php:5

    FAILURES!
    Tests: 1, Assertions: 0, Errors: 1.

    ///////////////////

    It seems that do not recognize any driver for MySql on PHP Ubuntu Installation

    1. matthias.kerstner Avatar

      Hi Alvaro,

      I believe your problem is not related to PHPUnit as such but to setting up MySQL/Yii in your XAMPP environment. I have used the setup described in this post for Windows systems as well (in conjunction with Cygwin).

      Does your Yii setup work without PHPUnit? Also please confirm that the MySQL executable is in your PATH so that it can be found by PHP. You also have to option to use a PHPUnit bootstrap file to set this path accordingly. Hope that helps. Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.