Download the PHP package jcergolj/rector-for-laravel without Composer

On this page you can find all versions of the php package jcergolj/rector-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rector-for-laravel

Laravel Rector Rules

A reusable Rector package for Laravel projects, containing custom rules and default configuration to enforce consistent refactoring patterns across multiple projects.


Installation

Install the package in your Laravel project:

This package also depends on:

These will be pulled in automatically if not already installed.

Requires PHP 8.3 or newer through driftingly/rector-laravel 2.7. Running this package's PHPUnit development suite requires PHP 8.4.1 or newer. Dependencies use stable releases by default.

driftingly/rector-laravel 2.7.3 requires the abandoned symplify/rule-doc-generator-contracts package, so Composer may print an abandonment warning. It does not prevent installation. There is no suggested replacement; removing it requires a change in the upstream Laravel Rector dependency, not simply deleting it from this package's dependencies.


⚙️ Usage Options

You can use the default rector.php config file in two ways:

✅ Option 1: Publish the Config to Project Root (Laravel Style)

You can publish the default rector.php file to the root of your Laravel project using:

This will copy rector.php from the package into the root of your Laravel project:

You can then modify this file to suit your project-specific rules and paths.


🟡 Option 2: Use the Config Directly from the Package

You can run Rector with the config file located in the package itself:

This is a good option if you want to keep the default setup with no local modifications.


Included Custom Rules

If you use this package's default rector.php config, all 14 custom rules documented below are enabled. Remove unwanted rules from your published config. In particular, the default config assumes intentionally unguarded models and forward-only migrations: disable RemoveFillableFromUnguardedModelsRector if you rely on $fillable allowlists, and RemoveMigrationDownMethodRector if you need migration rollbacks.

AddBlankLineAfterPhpUnitAssertionRector

Adds a blank line around assertions inside PHPUnit test methods so assertion blocks are easier to scan.

becomes:

This rule only targets PHPUnit test methods.

ArrowFunctionToClosureRector

Rewrites PHP arrow functions to equivalent closures with explicit use (...) captures.

becomes:

Preserves types, captures and function signatures, including nested arrows.

ModelCastsPropertyToCastsMethodRector

Converts Eloquent protected $casts = [...] properties into protected function casts(): array methods.

becomes:

Enable this only on Laravel versions that support defining model casts via a casts(): array method. The rule skips classes that already define casts().

ModelQueryToDirectStaticCallRector

Rewrites fluent Eloquent chains that start with Model::query() to the shorter direct static form when the rewrite is safe.

becomes:

Skips standalone query() calls and non-Eloquent classes.

PhpUnitTestDocblockToAttributeRector

Converts PHPUnit @test docblock annotations to the native PHP 8 #[Test] attribute.

becomes:

Preserves other annotations and avoids duplicate #[Test] attributes.

Additional Custom Rules

These rules are also enabled in the default config. The examples below show how to register or configure them when maintaining your own rector.php.

All WrapLong* rules use a configurable soft target of 120 characters, including indentation. They leave existing multiline layouts unchanged and may still produce lines over the target. Targets must be positive integers; Unicode characters count as one and tabs as four spaces. Run Pint after Rector for project styling.

WrapLongListsRector

Wraps long inline arrays, call argument lists and declaration parameter lists with one item per line. Supports nested arrays, function/method/constructor calls, closures, arrow functions and promoted constructor parameters. Enclosing multi-argument calls are expanded when their inline arrays need wrapping.

For example:

becomes:

Supports both [] and array(). Skips empty and single-item lists, existing multiline lists, first-class callable references and anonymous-class constructor argument lists. Never splits strings. Parameter-list length is measured through the closing parenthesis, excluding return types and bodies; parameter wrapping is skipped in files containing __LINE__.

WrapLongChainsRector

Wraps long method, property and mixed access chains before -> or ?->:

becomes:

Supports nested and nullsafe chains. Keeps the first access beside a variable receiver, and skips indivisible single accesses, existing multiline chains, dynamic property names and first-class callable chains.

The previous separate list and chain rules have been removed. Use the two merged rules above, with one shared MAX_LINE_LENGTH target per rule.

BlankLineBetweenStatementsRector

Adds a blank line between consecutive statements, even when they are closely related. Applies to functions, methods, closures, nested control-flow bodies and file-level code. Separates assignments, function/method/static calls (including throw_unless() and abort_if()), and boundaries before and after control flow. Consecutive use imports stay together, including function, constant and grouped imports. Existing blank lines between imports are preserved.

becomes:

Enable it explicitly:

Preserves existing blank lines, leading/trailing comment attachment, indentation and LF/CRLF line endings. Does not add trailing spaces, blank lines immediately inside braces, or spacing within a single statement (such as a for header). Class members and match arms are not separated. Match-arm spacing is a separate concern, not part of this rule. Works with AddBlankLineAfterPhpUnitAssertionRector and all WrapLong* rules, in either registration order.

Keep existing manual blank lines and AddBlankLineAfterPhpUnitAssertionRector; neither needs removing.

WrapLongConcatenationsRector

Wraps long concatenations with dots at the end of continued lines:

Enable it explicitly in your rector.php:

Supports nested concatenations in calls and arrays. Never splits string literals.

WrapLongBooleanConditionsRector

Wraps long if, elseif, while and do/while conditions using || or &&, with operators at the end of continued lines:

Enable it explicitly in your rector.php:

Preserves grouping and short-circuiting. Skips and, or, xor, for headers and boolean expressions outside these conditions.

MiddlewareTestsFirstRector

Moves tests calling assertMiddlewareIsApplied() before other tests, preserving order within each group.

becomes:

Non-test members stay in place. Calls inside closures or nested classes do not count. Skips classes with trailing inline member comments. Run Pint afterward if needed.

DataProviderBeforeTestRector

Moves each local PHPUnit data provider above the first test that uses it.

Supports #[DataProvider('method')] and @dataProvider method. Skips inherited, external and unused providers, and classes with trailing inline member comments. Works with MiddlewareTestsFirstRector. Run Pint afterward if needed.

To enable any of these test rules, add them to your rector.php:

RemoveFillableFromUnguardedModelsRector

Removes $fillable properties from Eloquent models for projects that intentionally run with unguarded models.

Only enable for unguarded models (Model::unguard() or equivalent). Unsafe if you rely on $fillable allowlists.

When maintaining your own rector.php, register the rule as follows:

Example:

becomes:

RemoveMigrationDownMethodRector

Removes down() methods from Laravel migrations for teams that intentionally do not keep migrations reversible.

Only enable for forward-only migrations. Do not use if your team needs migration rollbacks.

When maintaining your own rector.php, register the rule as follows:

Example:

becomes:


📄 License

This package is open-sourced software licensed under the MIT license.


All versions of rector-for-laravel with dependencies

PHP Build Version
Package Version
Requires driftingly/rector-laravel Version ^2.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jcergolj/rector-for-laravel contains the following files

Loading the files please wait ...