Install PHPUnit using PEAR in XAMPP

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

sudo ./pear channel-update
sudo ./pear channel-discover
sudo ./pear channel-discover
sudo ./pear channel-discover
sudo ./pear install --alldeps phpunit/PHPUnit

First, you (might have to) update PEAR with the changed protocols used by channel 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.

2 thoughts on “Install PHPUnit using PEAR in XAMPP”

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

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


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


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

    1. 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 Comment

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.

Scroll to Top