Installing the PHPUnit package
Since we're installing all dependencies throughout this book from the composer, we will do the same for PHPUnit:
composer require phpunit/phpunit
This also creates a symlink into vendor/bin/phpunit
, which we'll use to run our unit tests from the console.
PHPUnit supports multiple ways to install, including PHAR (PHP archive) format and installing it globally using the following:
composer global require phpunit/phpunit
Note
If you run into trouble installing PHPUnit, head over to the installation instructions at https://phpunit.de/manual/5.6/en/installation.html .
However, unless you have a good reason to use one global instance of PHPUnit, it's better to install it per project. This way we can avoid dealing with issues involving unit testing code written for different PHPUnit versions.