Upgrade your application with CLI without any deprecations knowledge.
Rector is a reconstructor tool - it does instant upgrades and instant refactoring of your code. I mean, why do it manually if 80 % can Rector handle for you?
Rector instantly upgrades PHP & YAML code of your application, with focus on open-source projects:
- Rename classes, methods and properties
- Rename partial namespace
- Rename pseudo-namespace to namespace
- Add, replace or remove arguments
- Add arguments or return typehint
- Change visibility of constant, property or method
- And much more...
...just look at overview of all available Rectors with before/after diffs and configuration examples. It's all you really need to use build your own sets.
composer require rector/rector:@dev --dev
Do you have conflicts on
Install prefixed version with isolated dependencies.
Rector relies on project and autoloading of its classes. To specify own autoload file, use
vendor/bin/rector process ../project --autoload-file ../project/vendor/autoload.php
Or make use of
# rector.yml parameters: autoload_files: - '%kernel.project_dir%/vendor/squizlabs/php_codesniffer/autoload.php' autoload_directories: - '%kernel.project_dir%/vendor/project-without-composer'
You can also exclude files or directories - use regex or fnmatch:
# rector.yml parameters: exclude_paths: - '*/src/*/Tests/*'
Featured open-source projects have prepared sets. You'll find them in
Do you need to upgrade to Symfony 4.0, for example?
Run rector on your
vendor/bin/rector process src --level symfony40
Which is a shortcut for using complete path with
vendor/bin/rector process src --config vendor/rector/rector/src/config/level/symfony/symfony40.yml
You can also use your own config file:
vendor/bin/rector process src --config your-own-config.yml
Do you want to see the preview of changes first?
vendor/bin/rector process src --level symfony33 --dry-run
To process just specific subdirectories, you can use fnmatch pattern with
vendor/bin/rector process "src/Symfony/Component/*/Tests" --level phpunit60 --dry-run
What levels are on the board?
rector.ymlwith desired Rectors:
services: Rector\Nette\Rector\Application\InjectPropertyRector: ~
Try Rector on your
vendor/bin/rector process src --dry-run
Apply the changes if you like them:
vendor/bin/rector process src
Rector uses EasyCodingStandard to improve the code style of changed files, like import namespaces, make 1 empty line between class elements etc.
It's always better to use own project's prepared set, but if you don't have the option yet, just use
--with-style option to handle these basic cases:
vendor/bin/rector process src --with-style
Just follow 3 rules:
1 feature per pull-request
New feature needs tests
Tests, coding standards and PHPStan checks must pass:
Don you need to fix coding standards? Run:
We would be happy to merge your feature then.