greg-1-anderson/composer-test-scenarios
Run Composer dependency test scenarios by quickly switching constraints and lockfiles in CI. Define multiple sets of requirements, install each scenario, and verify your package works across a matrix of versions and environments with minimal scripting.
Start by installing the package via Composer in your project:
composer require --dev greg-1-anderson/composer-test-scenarios
Then, add a composer-test-scenarios.json (or .dist) file to your project root. This JSON file defines sets of dependency variations (e.g., different versions of a critical package, PHP version constraints, or optional extension availability). The simplest first use case is testing compatibility across multiple versions of a single dependency—such as symfony/console—to catch regressions early.
Typical workflows involve defining scenario matrices in composer-test-scenarios.json, such as:
composer require foo/bar:~2.0 vs ~3.0 without manually editing composer.json.ext-redis, ext-imagick, etc., to verify fallback behavior.composer install and test runs per scenario.Example snippet:
{
"scenarios": [
{
"name": "symfony 5",
"require": {"symfony/console": "^5.4"}
},
{
"name": "symfony 6",
"require": {"symfony/console": "^6.3"}
}
]
}
Run scenarios locally via vendor/bin/composer-test-scenarios run, or integrate into your CI pipeline with commands like composer test-scenarios:run --scenario=symfony6.
composer.lock for each run—ensure your CI caches only the final state, or use --no-lock if appropriate.--verbose or output to separate logs per scenario.require, require-dev, and config can be overridden—replace and conflict cannot. Always double-check in composer.json afterward."config": {"ext-redis": "*"} } in a scenario to require it (not suggest it). Be aware some extensions don’t install cleanly in non-linux environments.How can I help you explore Laravel packages today?