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

7To5 Laravel Package

spatie/7to5

Abandoned. Converts PHP 7.0 code to PHP 5, useful when developing on PHP 7 but deploying to PHP 5. Provides a CLI to convert entire directories and rewrites features like anonymous classes, type hints, return types, and null coalescing.

View on GitHub
Deep Wiki
Context7

Convert PHP 7 code to PHP 5 code

Frequently asked questions about 7To5
Can spatie/7to5 convert Laravel 5.5+ code to PHP 5 for deployment?
No. Laravel 5.5+ dropped PHP 5.x support entirely, so this package won’t work unless you’re maintaining a parallel branch for Laravel ≤5.4. Even then, framework-specific syntax (e.g., Blade, Eloquent) may break.
How do I install spatie/7to5 for directory conversion?
Run `composer global require spatie/7to5` for global CLI access, then use `php7to5 convert <source> <destination>` to rewrite files. For project-specific use, add it to `require-dev` in `composer.json` and run via `./vendor/bin/7to5`.
Does this tool handle Laravel’s Blade templates or collect() methods?
No. Blade directives (e.g., `@php`) and Laravel’s fluent methods (e.g., `collect()->where()`) aren’t automatically converted. Manual fixes or exclusion from conversion are required.
What PHP 7 features does spatie/7to5 NOT support?
It skips complex constructs like `match` expressions, `foreach` with references, `array`/`object` destructuring, and dynamic code (e.g., `eval()`, `create_function()`). These will cause errors or require manual rewrites.
How can I test converted code for PHP 5 compatibility?
Run `php -l` on converted files for syntax errors, then test with PHP 5.6’s error reporting: `php -d error_reporting=E_ALL script.php`. Use PHPUnit 5.x for unit tests, but expect false positives in edge cases.
Is spatie/7to5 safe for production use? What risks exist?
No. The package is abandoned (last update: 2018) and may introduce logical errors (e.g., scope changes, performance regressions). Always review converted code manually and avoid converting third-party libraries.
Can I integrate this into a CI pipeline for automated PHP 5 checks?
Yes, but with caveats. Add a step like `./vendor/bin/7to5 --dry-run src/ && php -l converted_files/` to validate syntax. Disable it for Laravel 6+ projects or modern PHP stacks.
What are modern alternatives to spatie/7to5 for PHP 5 migration?
Consider `php-cs-fixer` with custom rules for syntax fixes, or Dockerize PHP 5.x for isolated legacy testing. For full migration, plan a phased upgrade to PHP 7.4+ (Laravel 8+) with feature flags.
How do I handle anonymous classes converted to named classes like `AnonymousClass0`?
The tool auto-generates unique class names, but this can cause collisions if the same anonymous class appears multiple times. Review converted files to rename classes manually or extend the tool’s logic.
Will this break Laravel’s service providers or Facades after conversion?
Likely. Service providers using PHP 7+ syntax (e.g., type-hinted bindings) or Facades relying on late static binding may fail. Test thoroughly and consider rewriting providers in PHP 5-compatible syntax.
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
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
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