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

Php Backport Laravel Package

dansan/php-backport

Dev tool to backport PHP source code for older runtimes (e.g., PHP 7.2+ features down to PHP 7.0). Configure directories to port, run a script on a *_bp branch, commit/push, then require the backported dev branch in Composer.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Legacy System Modernization: Enables gradual migration of PHP 7.2+ features into projects constrained to PHP 7.0, avoiding full version upgrades of dependent systems (e.g., Alpha).
  • Feature Parity Without Rewriting: Allows teams to retain modern PHP features (e.g., in Beta/Gamma) while supporting older ecosystems (e.g., Alpha), reducing technical debt.
  • Parallel Development Strategy: Supports a "build vs. buy" approach by enabling backporting as an alternative to rewriting or forcing upgrades.
  • Risk Mitigation: Reduces risk of breaking changes during migrations by isolating backported code in dedicated branches (*_bp).
  • Composer Dependency Management: Facilitates dependency alignment across parallel branches (e.g., master vs. master_bp) via automated composer.json updates.

When to Consider This Package

  • Legacy PHP Constraints: Use when a project must support PHP 7.0 but relies on libraries/modules requiring PHP ≥7.2.
  • Incremental Migration: Ideal for teams needing to backport specific features (e.g., type hints, spaceship operator) rather than upgrading entire systems.
  • Isolated Backport Needs: Not suitable for projects requiring full PHP version compatibility (e.g., PHP 8.x features in PHP 7.4). Consider alternatives like:
    • Polyfills (e.g., php-compat) for individual functions.
    • Docker/Containerization to isolate newer PHP versions.
    • Feature Flags to disable unsupported syntax.
  • Small-to-Medium Codebases: Best for projects with manageable AST transformations (e.g., <50K LoC). Large codebases may need custom visitor logic.
  • CI/CD Integration: Requires manual branch management (*_bp) and testing; automate only if CI pipelines can handle parallel branches.

How to Pitch It (Stakeholders)

Executives: "This package lets us keep using modern PHP features (e.g., type safety, null coalescing) in our core libraries (Beta/Gamma) while still supporting legacy systems (Alpha) running PHP 7.0. Instead of forcing a costly upgrade of Alpha or rewriting features, we can backport only what’s needed—reducing risk and saving dev time. It’s a low-cost way to maintain feature parity without disrupting production."

Engineering/Tech Leads: *"The dansan/php-backport package automates the conversion of PHP 7.2+ syntax to PHP 7.0-compatible code using AST parsing (via nikic/php-parser). Here’s how it fits:

  • Workflow: Develop on master (PHP ≥7.2), then merge to master_bp and run php bin/backport.php to generate 7.0-compatible code.
  • Dependencies: Automatically updates composer.json to point to backported branches (e.g., dev-master_bp@dev).
  • Safety: Blocks execution unless on a _bp branch; conflicts are resolved by accepting master changes (since backported code is derived).
  • Trade-offs: Adds a parallel branch overhead but avoids rewrites or forced upgrades. Best for targeted feature backports, not full version compatibility."*

Developers: *"Need to support PHP 7.0 but want to use PHP 7.2+ features? This tool:

  1. Parses your src/ and tests/ directories.
  2. Transforms modern PHP syntax to work in PHP 7.0.
  3. Updates composer.json to reference backported dependencies.
  4. Lets you test and commit the changes to a _bp branch. Example:
git checkout -b master_bp
php bin/backport.php
composer update
test
git push origin master_bp

It’s like a time machine for PHP—just don’t run it on master!"*

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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony