roave/backward-compatibility-check
Checks your PHP library for backward compatibility breaks between git tags/versions. Designed for CI: compares the last SemVer tag to current HEAD, reports API breaks, and exits non-zero on failure. Install via Composer or run in Docker.
Strengths:
1.x.x for minor releases, 2.x.x for major). Enforces backward compatibility (BC) checks before releases, reducing post-release churn.composer.json autoloading and Git tags—native to Laravel’s workflow.phpunit/pest testing suites.Gaps:
call_user_func).Low-Friction Setup:
composer require --dev command; no Laravel service provider or config file needed.composer.json autoload paths (e.g., psr-4, classmap).CI/CD Plug-and-Play:
nyholm/roave-bc-check-ga) reduces setup time to <5 minutes.github-actions, markdown, and json for integration with Slack/Teams or changelog generation.handle() in Jobs) may trigger false BC alerts..roave-backward-compatibility-check.xml to whitelist known non-breaking changes (e.g., ignored-regex for Facade method additions).composer.json autoload paths be structured?phpunit) or pre-deploy (before tagging).markdown/json for changelogs (e.g., Laravel’s release notes).composer.json dev dependencies:
composer require --dev roave/backward-compatibility-check
jobs:
bc-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Critical for tag detection
- run: composer install
- run: vendor/bin/roave-backward-compatibility-check --format=github-actions
ignored-regex to exclude:
<ignored-regex>#\[BC\] CHANGED: The method Illuminate\\Support\\Facades\\Config::get\(\)#</ignored-regex>
App\Services\*) may need manual review.handle()) require explicit handling.composer.json autoload paths are included in the global autoload section.| Phase | Action | Tools/Artifacts |
|---|---|---|
| Pre-Release | Run BC check after phpunit but before tagging. |
GitHub Actions, roave-backward-compatibility-check |
| Post-Merge | Use --format=github-actions to annotate PRs with BC warnings. |
GitHub PR comments |
| Release | Generate markdown output for changelogs. |
results.md → Laravel’s release notes |
| Maintenance | Periodically review ignored BC changes in .roave-backward-compatibility-check.xml. |
Config file, team syncs |
.roave-backward-compatibility-check.xml may accumulate ignored rules, reducing effectiveness.8.21.0) in composer.json.composer.json autoload.fetch-depth: 0. Add to CI config (see GitHub Actions example).[BC] REMOVED: Method App\Models\User::oldMethod()).How can I help you explore Laravel packages today?