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

Rector Laravel Package

contao/rector

Automate Contao CMS code upgrades with Rector rules and presets. contao/rector helps refactor PHP codebases to newer Contao and PHP versions, applying safe transformations to reduce manual migration work and keep projects consistent.

View on GitHub
Deep Wiki
Context7

Rector configurations for Contao

Frequently asked questions about Rector
Can I use contao/rector to upgrade a Contao 4 project to Contao 5 automatically?
Yes, contao/rector includes presets specifically for Contao 4→5 migrations, handling deprecated APIs, template engine changes, and DCA adjustments. Run it via `./vendor/bin/rector process` after installation, but always test in a staging environment first due to potential edge cases in custom extensions.
Will contao/rector break my custom Contao extensions?
There’s a risk, especially if your extensions rely on deprecated Contao syntax or hooks. Start with a `--dry-run` to preview changes, then manually validate extensions. The package prioritizes core Contao refactoring, but custom logic may need manual adjustments.
How do I install contao/rector in a Laravel project with Contao integration?
Add it via Composer: `composer require contao/rector`. Ensure Rector (rector/rector) is installed as a dependency. Run it in your Contao root directory, not the Laravel root, since it targets Contao’s PHP codebase. Use `--config` to point to a custom Rector config if needed.
Does contao/rector support PHP 8.1+ for Contao 5 projects?
Yes, contao/rector aligns with Contao 5’s PHP 8.0+ requirement. It includes rules for modern PHP syntax (e.g., named arguments, union types) alongside Contao-specific refactoring. Verify your Contao version’s PHP support matrix to avoid conflicts.
Can I run contao/rector in CI/CD to enforce Contao coding standards?
Absolutely. Add it to your CI pipeline (e.g., GitHub Actions) with a step like `./vendor/bin/rector process --level=max`. Use `--fail-on-no-changes` to block PRs if no refactoring occurs, ensuring consistency. Pair it with PHPStan for static analysis.
What if my project already uses custom Rector rules?
Merge conflicts are possible. Use `--config` to combine contao/rector’s presets with your existing rules, or override specific rules in a custom config file. Test thoroughly, as Contao’s dynamic template engine may interact unpredictably with generic Rector rules.
Are there performance concerns for large Contao installations?
Yes, Rector can be resource-intensive on large codebases (e.g., 100K+ files). Optimize by running it incrementally (e.g., `--parallel` for file processing) or targeting specific directories like `templates/` or `system/`. Monitor memory usage in CI to avoid timeouts.
How do I handle Contao templates and frontend output after refactoring?
Contao templates are sensitive to syntax changes. After running Rector, manually test frontend output by comparing before/after snapshots. Use Contao’s built-in testing tools (e.g., `contao:test`) to validate rendering. Focus on custom templates first, as core templates are less likely to break.
What’s the rollback plan if contao/rector breaks production?
Maintain a backup of your `vendor/` directory before running Rector. For critical issues, revert to the backup and reapply changes incrementally. Use Git to track refactoring commits, allowing you to revert specific changes if needed.
Are there alternatives to contao/rector for Contao migrations?
For Contao-specific upgrades, contao/rector is the most targeted option. Alternatives like generic Rector presets (e.g., `rector/rector-preset`) lack Contao’s DCA/template engine awareness. For manual upgrades, Contao’s official migration guides or custom scripts may suffice, but they require deeper Contao expertise.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky