Collision Documentation

repository·v8.x·Indexed 26 days ago

https://github.com/nunomaduro/collision

Collision 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.

Tokens
864
Snippets
3
Records
7
Agent score
39%

What's inside Collision

  1. Run tests in parallel

    v8.x

    Use 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.
  2. Register the Collision handler manually

    v8.x

    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();
  3. Check Collision version compatibility

    v8.x

    Collision version requirements vary based on your framework and testing tools. Refer to the compatibility matrix below:

    LaravelCollisionPHPUnitPest
    6.x3.x
    7.x4.x
    8.x5.x
    9.x, 10.x6.x
    10.x6.x9.x1.x
    10.x7.x10.x2.x
    11.x, 12.x8.x10.x, 11.x, 12.x, 13.x2.x, 3.x, 4.x, 5.x
  4. Reference: `php artisan test` options

    v8.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 performed