Install Collision via Composer
v8.xTo install Collision as a development dependency, use Composer. Note that Collision requires PHP 8.2+.
composer require nunomaduro/collision --devrepository·v8.x·Indexed 26 days ago
https://github.com/nunomaduro/collisionCollision provides high-quality error reporting for PHP applications interacting via the command line. Built on Whoops and widely used in the Laravel ecosystem, it requires PHP 8.2+. It includes a Laravel adapter providing the `php artisan test` command for running PHPUnit and Pest tests with enhanced error reporting, code coverage enforcement, and parallel execution support via ParaTest.
To install Collision as a development dependency, use Composer. Note that Collision requires PHP 8.2+.
composer require nunomaduro/collision --devUse the --parallel (or -p) flag to run tests in parallel. This utilizes ParaTest and the Laravel Parallel Testing runner. When using parallel testing, you can also control database and cache behavior:
--recreate-databases: Re-create test databases.--drop-databases: Drop test databases.--without-databases: Skip database configuration.--without-cache: Skip cache configuration.You can collect code coverage and enforce a minimum percentage threshold using the --coverage and --min flags. If the coverage falls below the specified threshold, the command will exit with a failure status.
Requirements: A coverage driver like Xdebug or PCOV must be installed and configured.
If you are not using a framework that automatically integrates Collision, you must manually register the handler in your code using the Provider class.
(new \NunoMaduro\Collision\Provider)->register();Collision version requirements vary based on your framework and testing tools. Refer to the compatibility matrix below:
| Laravel | Collision | PHPUnit | Pest |
|---|---|---|---|
| 6.x | 3.x | ||
| 7.x | 4.x | ||
| 8.x | 5.x | ||
| 9.x, 10.x | 6.x | ||
| 10.x | 6.x | 9.x | 1.x |
| 10.x | 7.x | 10.x | 2.x |
| 11.x, 12.x | 8.x | 10.x, 11.x, 12.x, 13.x | 2.x, 3.x, 4.x, 5.x |
The following flags are available for the test command to control test execution, coverage, and environment configuration.
--without-tty : Disable output to TTY
--compact : Indicates whether the compact printer should be used
--coverage : Indicates whether code coverage information should be collected
--min= : Indicates the minimum threshold enforcement for code coverage
--p|parallel : Indicates if the tests should run in parallel
--profile : Lists top 10 slowest tests
--recreate-databases : Indicates if the test databases should be re-created
--drop-databases : Indicates if the test databases should be dropped
--without-databases : Indicates if database configuration should be performed
--without-cache : Indicates if cache configuration should be performedThe test Artisan command is provided by the Collision Laravel adapter to run application tests with enhanced error reporting and coverage capabilities. It supports both PHPUnit and Pest, and can run tests in parallel using ParaTest.
Note: Running in parallel requires brianium/paratest 7.x or higher.