How to install phpunit in centos

This post will show you how to install phpunit in centos using pear or composer. I prefer using composer as its mega easy to add lots of cool stuff and keep it all updated.

Install phpunit in centos with composer.

Firstly, If you don’t have composer, then you’ll need to install composer.

For a system-wide installation of phpunit using composer, you can run:

composer global require "phpunit/phpunit=4.1.*"

You’ll need to make sure you have ~/.composer/vendor/bin/ in your path so that you can run composer form anywhere on your system.

or, you can install phpunit as a dependency in a single project, to do this you need to add

{
    "require-dev": {
        "phpunit/phpunit": "4.1.*"
    }
}

to the .composer.json file in the root directory of your project and run ‘composer update’ in the root folder of your project.

Install phpunit in centos with PEAR.

note: this method is now deprecated, please use the composer way instead.

1) install pear if you dont already have it.

sudo yum install php-pear

2) check your pear is up-to-date.

sudo pear upgrade pear

3) add the channels required.

sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover pear.symfony.com
sudo pear channel-discover components.ez.no

4) install phpunit and its dependancies.

sudo pear install --alldeps phpunit/PHPUnit

5) phpunit should now be installed.

phpunit

Leave a Reply