Weave 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 Rules

Rector Rules Laravel Package

pekral/rector-rules

A set of custom Rector rules for Laravel and PHP projects that automate code modernization, refactoring, and upgrade tasks. Helps enforce best practices and reduce manual migration effort across your codebase.

Deep Wiki
Context7

Curated Rector rule set for PHP 8.4+ — 228 hand-picked rules in one import, with every other rule listed as skipped.

Frequently asked questions about Rector Rules
What is pekral/rector-rules used for?
pekral/rector-rules is a Composer package that provides custom Rector rules for PHP and Laravel codebases. It helps automate repetitive refactoring, enforce coding standards, and modernize legacy code. You add the rules to your rector.php configuration so Rector can apply consistent changes across your project.
How do I install pekral/rector-rules?
Install the package with Composer, typically as a development dependency because it is a refactoring tool rather than runtime code. Run composer require --dev pekral/rector-rules in your project root. After installation, register the rules in your Rector configuration file.
How do I add pekral/rector-rules to my rector.php configuration?
Import the rule classes or provided rule set into your rector.php file and register them with Rector's withRules or withSets configuration methods. The package is designed to plug into a standard Rector setup. Check the package documentation for the exact rule class names and any recommended configuration order.
Can pekral/rector-rules be combined with existing Rector rule sets?
Yes, the package is intended to work alongside your existing Rector rule sets. You can register its rules in the same rector.php configuration you already use for framework or coding-standard upgrades. Rule order can matter in Rector, so review diffs when combining multiple sets.
Does pekral/rector-rules work with Laravel projects?
Yes, the package targets both PHP and Laravel projects and includes rules for common Laravel refactorings. The exact Laravel versions supported depend on the package's Composer constraints. Check its composer.json or Packagist page before adding it to an older or very new Laravel application.
Can I use pekral/rector-rules for gradual refactoring of legacy code?
Yes, Rector is well suited to gradual adoption because you can run it on selected paths or rule sets and review the diffs before committing. Start with one directory or a small set of rules, then expand coverage as you gain confidence. Committing changes in small batches keeps legacy migrations safe and reviewable.
How do I preview changes before Rector applies them?
Run Rector with the dry-run option first so it shows the proposed diffs without modifying files. Review those diffs in your terminal or version control, then rerun without dry-run to apply the changes. Always work on a clean branch so you can easily revert unwanted refactorings.
Is pekral/rector-rules safe to run in CI or on production code?
It is a development and refactoring tool, so it should not be required at runtime in production. In CI you can run Rector in dry-run mode to check that code matches the expected rules without changing files. Apply the rules locally or in a dedicated refactoring branch, then review and test the resulting changes.
How do I exclude files or directories from pekral/rector-rules?
The package's rules run within Rector's normal file selection, so use Rector's paths and skip configuration in rector.php to exclude files or directories. This lets you keep generated code, migrations, or third-party packages out of the refactoring process. Confirm exclusions with a dry run before applying changes broadly.
Where can I find documentation and report issues for pekral/rector-rules?
The package is distributed on Packagist under the name pekral/rector-rules, so its Packagist page is the best starting point for the current source repository and release history. The repository URL was not included in the provided package details, so check Packagist for the official issue tracker. Report bugs or rule suggestions there with a minimal reproduction and your Rector version.
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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle