Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Backward Compatibility Check Laravel Package

roave/backward-compatibility-check

CLI tool to detect backward-compatibility breaks between two versions of a PHP library. Compares the last SemVer git tag to current HEAD (or chosen refs) and fails CI on API breaks. Install via Composer or run with Docker.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel/PHP Ecosystem Alignment: The package is highly relevant for Laravel projects, as Laravel follows Semantic Versioning (SemVer) and maintains strict backward compatibility (BC) guarantees. This tool directly supports Laravel’s API stability goals by enforcing BC checks during development and CI.
  • Static Analysis Focus: The tool leverages PHP’s reflection API and Nikic’s PHP Parser to analyze class APIs (methods, properties, enums, etc.), making it a complementary tool to Laravel’s existing testing suite (PHPUnit, Pest). It does not replace unit/integration tests but augments them by catching API-level regressions early.
  • Integration with Laravel’s Workflow:
    • Works seamlessly with Laravel’s composer.json autoloading.
    • Supports Laravel’s Git-based release process (tags for versioning).
    • Can be embedded in Laravel’s CI/CD pipelines (e.g., GitHub Actions, GitLab CI) to block BC-breaking changes.

Integration Feasibility

  • Low-Coupling Design: The package is self-contained and does not require modifications to Laravel’s core. It operates on codebase snapshots (via Git) and Composer autoload paths, making integration non-intrusive.
  • Pre-requisites:
    • Git tags (SemVer-compliant, e.g., v1.0.0): Laravel already uses this for releases.
    • Composer autoload: Laravel’s composer.json already defines autoload paths.
    • PHP 8.1+: Laravel 10+ supports PHP 8.2/8.3; the package supports up to PHP 8.4 (as of v8.12.0).
  • Tooling Compatibility:
    • Works with Laravel Forge, Laravel Vapor, and Laravel Sail (Docker-based) environments.
    • Can be containerized (Docker support provided) for CI/CD isolation.

Technical Risk

Risk Area Assessment Mitigation
False Positives The tool may flag intentional API changes (e.g., deprecations, internal methods) as BC breaks. Laravel’s codebase has internal classes/methods (e.g., Illuminate\Support\Traits) that should be excluded. Use .roave-backward-compatibility-check.xml to ignore known BC-safe changes (e.g., internal methods, @internal annotations).
Performance Overhead Static analysis of large codebases (e.g., Laravel + packages) may slow down CI. Run in parallel with other CI jobs or cache results (e.g., GitHub Actions artifact caching). Use --format=json for machine-readable output to avoid reprocessing.
Enum/Attribute Support Laravel 10+ uses enums and attributes; the package supports enum changes (v8.8.0+) but may miss edge cases (e.g., custom attributes). Test with Laravel’s enum-heavy packages (e.g., spatie/laravel-permission) to validate coverage.
CI Configuration Complexity Requires full Git history (fetch-depth: 0) and tag fetching, which may not be enabled in all Laravel CI setups. Document CI setup requirements in Laravel’s README.md or .github/workflows/. Use the Nyholm GitHub Action for simplicity.
Dependency Conflicts The package depends on nikic/php-parser:^5.4 and vimeo/psalm:^6, which may conflict with Laravel’s dependencies (e.g., older PHP versions). Pin versions in composer.json or use --dev isolation. Test with Laravel’s minimum supported PHP version.

Key Questions for TPM

  1. BC Policy Alignment:
    • Does Laravel’s current BC policy (e.g., Laravel’s SemVer adherence) need adjustments to accommodate this tool? For example, should internal APIs be explicitly excluded?
  2. CI/CD Impact:
    • How will this tool interact with existing CI checks (e.g., PHPUnit, Pest, Psalm)? Should it run before or after tests?
    • What failure thresholds should be set (e.g., block all BC breaks vs. allow minor ones with warnings)?
  3. Developer Adoption:
    • How will contributors (core team, community) be trained to interpret BC reports and update the ignore list (roave-backward-compatibility-check.xml)?
  4. Long-Term Maintenance:
    • Who will maintain the ignore list as Laravel evolves? Should this be automated (e.g., via a bot) or manual?
  5. Tooling Extensions:
    • Could this tool be extended to integrate with Laravel’s deprecation system (e.g., @deprecated annotations) or migration system (e.g., flagging BC breaks in Illuminate\Database schema changes)?

Integration Approach

Stack Fit

  • Laravel Core:

    • Best Fit: Laravel’s framework codebase, core packages (e.g., illuminate/, laravel/), and official addons (e.g., spatie/laravel-*).
    • Why: These components must maintain strict BC for Laravel’s ecosystem. The tool will catch regressions in:
      • Facade/Service Container (Illuminate\Container).
      • Database Layer (Illuminate\Database).
      • HTTP Layer (Illuminate\Http).
      • Queue/Events (Illuminate\Queue, Illuminate\Events).
    • Less Fit: Userland packages (e.g., laravel-excel) or third-party integrations (e.g., tightenco/ziggy), where BC is managed by package maintainers.
  • Laravel Ecosystem:

    • Forge/Vapor: Useful for hosting providers to ensure their Laravel-based services don’t break when updating Laravel core.
    • Laravel Mix/Vite: Less relevant (focused on frontend assets), but could be used to audit build scripts (e.g., mix.js() API changes).

Migration Path

Phase Action Tools/Artifacts
Pilot (Core Team) 1. Add to Laravel’s CI: Integrate into laravel/framework’s GitHub Actions. .github/workflows/backward-compatibility.yml, composer.json (dev dependency).
2. Baseline Configuration: Create .roave-backward-compatibility-check.xml to ignore known BC-safe changes (e.g., internal methods, @internal classes). roave-backward-compatibility-check.xml (initial version).
3. Test with Major Releases: Run against LTS branches (e.g., 10.x, 9.x) to validate false positives/negatives. Git tags (v10.0.0, v9.50.0).
Rollout (Ecosystem) 4. Document for Packages: Publish a Laravel-specific guide on how to adopt the tool. Laravel Docs (laravel.com/docs/extending/backward-compatibility).
5. GitHub Action Template: Provide a pre-configured action for Laravel packages. Fork of Nyholm’s action with Laravel defaults.
Optimization 6. Performance Tuning: Cache results in CI, parallelize runs. GitHub Actions cache, concurrently for local dev.
7. Ignore List Automation: Explore bot-driven updates to the ignore list (e.g., via PRs for new @internal annotations). GitHub App or Laravel’s laravel-shift bot.

Compatibility

  • Laravel Versions:
    • Supported: Laravel 9+ (PHP 8.0+) to Laravel 11 (PHP 8.4+).
    • Limitations:
      • Laravel 8: May require older package versions (e.g., roave/backward-compatibility-check:^8.0).
      • **
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation