Pre-configured quality tools for PHP projects (Rector, PHP-CS-Fixer, Twig-CS-Fixer). Symfony, Laravel, and framework-agnostic configurations with automatic framework detection.
nowo-tech/php-quality-tools is a Laravel package for pre-configured quality tools for php projects (rector, php-cs-fixer, twig-cs-fixer). symfony, laravel, and framework-agnostic configurations with automatic framework detection..
It currently has 0 GitHub stars and 2.657 downloads on Packagist (latest version v1.0.15).
Install it with composer require nowo-tech/php-quality-tools.
Discover more Laravel packages by nowo-tech
or browse all Laravel packages to compare alternatives.
Last updated
⭐ Found this useful? Give it a star on GitHub! It helps us maintain and improve the project.
Pre-configured quality tools for PHP projects. Includes ready-to-use configurations for:

This bundle is FrankenPHP worker mode friendly.
*.custom.php files for project-specific settingscomposer require --dev nowo-tech/php-quality-tools
During installation, the plugin will:
Example output:
php-quality-tools: Detected framework: symfony
php-quality-tools: Installing .rector.php
php-quality-tools: Installing .rector.custom.php
php-quality-tools: Installing .php-cs-fixer.php
php-quality-tools: Installing .php-cs-fixer.custom.php
php-quality-tools: Installing .twig-cs-fixer.php
php-quality-tools: Installing .twig-cs-fixer.custom.php
php-quality-tools: Installed 6 file(s) for symfony
Note: If Twig is not installed, you'll see:
php-quality-tools: Twig not detected, skipping Twig-CS-Fixer configuration
Then you may see:
php-quality-tools: Missing suggested dependencies detected:
- rector/rector: Rector for automated code refactoring
- rector/rector-symfony: Rector rules for Symfony (only for Rector 1.x)
- rector/rector-doctrine: Rector rules for Doctrine (only for Rector 1.x)
- rector/rector-phpunit: Rector rules for PHPUnit (only for Rector 1.x)
- friendsofphp/php-cs-fixer: PHP-CS-Fixer for code style fixing
- vincentlanglet/twig-cs-fixer: Twig-CS-Fixer for Twig template style fixing
Would you like to install these dependencies now? (yes/no) [yes]: yes
php-quality-tools: Installing dependencies...
php-quality-tools: Dependencies installed successfully!
Note: If you're using Rector 2.x, the optional packages (rector-symfony, rector-doctrine, rector-phpunit) will be automatically skipped as they are not compatible with Rector 2.x yet.
If you choose yes, dependencies will be installed automatically. If no, you can install them manually later.
If you prefer to install dependencies manually or in non-interactive mode:
Note: The plugin automatically detects your Rector version:
# For Symfony projects (Rector 1.x)
composer require --dev rector/rector rector/rector-symfony:^1.0 rector/rector-doctrine:^0.16 rector/rector-phpunit:^1.0 friendsofphp/php-cs-fixer vincentlanglet/twig-cs-fixer
# For Symfony projects (Rector 2.x)
# Note: Optional Rector packages are NOT compatible with Rector 2.x
composer require --dev rector/rector friendsofphp/php-cs-fixer vincentlanglet/twig-cs-fixer
# For Laravel projects
composer require --dev rector/rector driftingly/rector-laravel friendsofphp/php-cs-fixer
# For generic PHP projects
composer require --dev rector/rector friendsofphp/php-cs-fixer vincentlanglet/twig-cs-fixer
After installation, the following files are created in your project root:
| File | Purpose | Overwritten on update? |
|------|---------|------------------------|
| .rector.php | Rector main config | ❌ Never |
| .rector.custom.php | Your customizations | ❌ Never |
| .php-cs-fixer.php | PHP-CS-Fixer main config | ❌ Never |
| .php-cs-fixer.custom.php | Your customizations | ❌ Never |
| .twig-cs-fixer.php | Twig-CS-Fixer main config (if twig/twig installed) | ❌ Never |
| .twig-cs-fixer.custom.php | Your customizations (if twig/twig installed) | ❌ Never |
Template Engine Support:
twig/twig is detected (works with Symfony, Laravel, Yii, CakePHP, Laminas, Slim, Generic).blade.php files included automatically)# Preview changes
./vendor/bin/rector process --dry-run
# Apply changes
./vendor/bin/rector process
# Preview changes
./vendor/bin/php-cs-fixer fix --dry-run --diff
# Apply changes
./vendor/bin/php-cs-fixer fix
Note: Twig-CS-Fixer configuration is automatically installed if twig/twig is detected in your project dependencies, regardless of framework.
Supported frameworks: Symfony (default), Laravel (optional), Yii (optional), CakePHP (optional), Laminas (optional), Slim (optional), Generic
# Check for issues
./vendor/bin/twig-cs-fixer lint templates/
# Fix issues
./vendor/bin/twig-cs-fixer lint --fix templates/
Laravel Blade templates (.blade.php files) are PHP files with special syntax and can be formatted using PHP-CS-Fixer. The Laravel configuration includes .blade.php files automatically.
# Format Blade templates (included in PHP-CS-Fixer)
./vendor/bin/php-cs-fixer fix resources/views --dry-run --diff
./vendor/bin/php-cs-fixer fix resources/views
Note: Some Blade-specific directives (like @if, @foreach, etc.) may need manual review after formatting, as PHP-CS-Fixer treats them as PHP code.
The package automatically detects your framework and installs the appropriate configuration:
| Framework | Detection | Rector | PHP-CS-Fixer | Template Engine | Template Formatter |
|-----------|-----------|--------|--------------|----------------|-------------------|
| Symfony | symfony/framework-bundle | ✅ Symfony-specific | ✅ | Twig (default) | ✅ Twig-CS-Fixer (if twig/twig installed) |
| Laravel | laravel/framework | ✅ Laravel-specific | ✅ (includes Blade) | Blade (default), Twig (optional) | ✅ PHP-CS-Fixer for Blade |
| Yii | yiisoft/yii2 | ✅ Generic | ✅ | PHP native views, Twig (optional) | ✅ Twig-CS-Fixer (if twig/twig installed) |
| CakePHP | cakephp/cakephp | ✅ Generic | ✅ | PHP native (.ctp files), Twig (optional) | ✅ Twig-CS-Fixer (if twig/twig installed) |
| Laminas | laminas/laminas-mvc | ✅ Generic | ✅ | PHP native, Twig (optional), Smarty (optional) | ✅ Twig-CS-Fixer (if twig/twig installed) |
| CodeIgniter | codeigniter4/framework | ✅ Generic | ✅ | PHP native views | ❌ No formatter available |
| Slim | slim/slim | ✅ Generic | ✅ | PHP native, Twig (optional) | ✅ Twig-CS-Fixer (if twig/twig installed) |
| Other | - | ✅ Generic | ✅ | Varies (Twig, PHP native, etc.) | ✅ Twig-CS-Fixer (if twig/twig installed) |
Note: Template formatter configurations are only installed if the corresponding template engine is detected in your dependencies. For example, Twig-CS-Fixer config is only installed if twig/twig is present in your composer.json.
| Version | PHP | Symfony | Laravel | Composer | |---------|-----|---------|---------|----------| | 1.0.x (1.0.0 – 1.0.13) | >= 8.1 | 6.0 - 8.1 | 9.0 - 11.0 | >= 2.0 |
Opt-in installation: By default, the plugin does not modify your composer.json. To have quality scripts added automatically (only missing keys; existing scripts are never overwritten), enable:
{
"extra": {
"php-quality-tools": {
"auto_add_scripts": true
}
}
}
Then run composer update nowo-tech/php-quality-tools or composer install. You will see a confirmation when scripts are added.
The following scripts can be added (if they don't already exist):
All frameworks:
fix:check - Check code style with PHP-CS-Fixer (dry-run)fix - Fix code style with PHP-CS-Fixerrector:check - Preview Rector changes (dry-run)rector - Apply Rector changestest - Run PHPUnit tests (if phpunit is installed)If Twig is installed:
twig:lint - Lint Twig templates (dry-run)twig:fix - Fix Twig templatestwig:fix:check - Check and fix Twig templatesLaravel only:
blade-check - Check Blade templates (dry-run)blade-fix - Fix Blade templatesNote: Existing scripts in your composer.json are never overwritten. The plugin only adds missing scripts when auto_add_scripts is true.
Note: The plugin preserves your composer.json formatting (2 spaces, 4 spaces, or tabs) when adding scripts. Your original indentation style is maintained.
Note: The plugin preserves the original order of your existing scripts. New scripts are added at the beginning of the scripts section, so your preferred organization is maintained.
If you prefer different script names or commands, you can manually add them to your composer.json:
{
"scripts": {
"fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes",
"fix:check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config=.php-cs-fixer.php --dry-run --diff --allow-risky=yes",
"rector": "rector process -c .rector.php",
"rector:check": "rector process -c .rector.php --dry-run",
"twig:fix": "twig-cs-fixer fix --config=.twig-cs-fixer.php",
"twig:lint": "twig-cs-fixer lint --config=.twig-cs-fixer.php",
"twig:fix:check": "twig-cs-fixer lint --config=.twig-cs-fixer.php --fix",
"blade-check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix resources/views --config=.php-cs-fixer.php --dry-run --diff --allow-risky=yes",
"blade-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix resources/views --config=.php-cs-fixer.php --allow-risky=yes"
}
}
After enabling auto_add_scripts (or adding scripts manually), you can run:
# PHP-CS-Fixer (automatically installed)
composer fix:check # Check code style (dry-run)
composer fix # Fix code style
# Rector (automatically installed)
composer rector:check # Preview changes (dry-run)
composer rector # Apply changes
# Template Formatters (if dependencies are installed)
# Twig-CS-Fixer (automatically installed if Twig is present)
composer twig:lint # Lint Twig templates (dry-run)
composer twig:fix # Fix Twig templates
composer twig:fix:check # Check and fix Twig templates
# Blade Templates (Laravel only, automatically installed)
composer blade-check # Check Blade templates (dry-run)
composer blade-fix # Fix Blade templates
# Tests (automatically installed if PHPUnit is present)
composer test # Run PHPUnit tests
Note: Enable auto_add_scripts or add scripts manually (see sections above). If you rely on the plugin defaults, set extra.php-quality-tools.auto_add_scripts to true.
All customizations go in the *.custom.php files. These files are never overwritten.
Edit .rector.custom.php:
<?php
return [
'paths' => [
__DIR__ . '/src',
__DIR__ . '/tests',
],
'skip' => [
__DIR__ . '/src/Legacy/*',
\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class,
],
'php_version' => 'php84',
'symfony_version' => 74, // For Symfony projects
'features' => [
'type_declarations' => true,
'dead_code' => true,
'code_quality' => true,
'early_return' => true,
'naming' => true,
'privatization' => true,
],
];
Edit .php-cs-fixer.custom.php:
Project Custom Fixers:
You can add your own project-specific custom fixers by adding them to the project_custom_fixers array:
return [
// ... other settings ...
'project_custom_fixers' => [
\App\Fixer\Custom\MyCustomFixer::class,
// Add more custom fixers here
],
];
Your project custom fixers will be automatically registered alongside PHP Quality Tools fixers. This allows you to extend functionality with project-specific code style rules.
<?php
return [
'paths' => [
__DIR__ . '/src',
__DIR__ . '/tests',
],
'exclude' => [
'vendor',
'var',
'src/Legacy',
],
'rules' => [
// Override or add rules
'concat_space' => ['spacing' => 'none'],
'yoda_style' => true,
],
];
Edit .twig-cs-fixer.custom.php:
<?php
return [
'paths' => [
__DIR__ . '/templates',
__DIR__ . '/src/Resources/views',
],
'exclude' => [
'vendor',
],
'disabled_rules' => [
// Disable specific rules
],
];
This package provides configurations and can automatically install the required tools during installation.
The plugin will detect missing dependencies and offer to install them automatically. Just answer yes when prompted.
If you prefer to install manually or the automatic installation didn't work:
composer require --dev \
rector/rector \
rector/rector-symfony \
rector/rector-doctrine \
rector/rector-phpunit \
friendsofphp/php-cs-fixer \
vincentlanglet/twig-cs-fixer
composer require --dev \
rector/rector \
driftingly/rector-laravel \
friendsofphp/php-cs-fixer
composer require --dev \
rector/rector \
friendsofphp/php-cs-fixer \
vincentlanglet/twig-cs-fixer
Add to your Makefile:
.PHONY: cs cs-fix rector rector-fix lint
# Check code style
cs:
./vendor/bin/php-cs-fixer fix --dry-run --diff
# Fix code style
cs-fix:
./vendor/bin/php-cs-fixer fix
# Preview Rector changes
rector:
./vendor/bin/rector process --dry-run
# Apply Rector changes
rector-fix:
./vendor/bin/rector process
# Template Formatters
# Check Twig templates
twig-lint:
./vendor/bin/twig-cs-fixer lint templates/
# Fix Twig templates
twig-fix:
./vendor/bin/twig-cs-fixer lint --fix templates/
# Check Blade templates (Laravel)
blade-lint:
./vendor/bin/php-cs-fixer fix resources/views --dry-run --diff
# Fix Blade templates (Laravel)
blade-fix:
./vendor/bin/php-cs-fixer fix resources/views
# Run all checks
lint: cs rector twig-lint
name: Code Quality
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer install
- name: PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
- name: Rector
run: ./vendor/bin/rector process --dry-run
When you update this package:
composer update nowo-tech/php-quality-tools
*.custom.php) are preserved.rector.php, .php-cs-fixer.php, etc.) are created on both composer install and composer update if they do not exist yetImportant: Existing files are never overwritten. The plugin only copies a template when the target file is absent. To replace a main config with a fresh template from the package, remove that file and run composer install or composer update:
rm .rector.php .php-cs-fixer.php .twig-cs-fixer.php
composer install
For detailed upgrade instructions, breaking changes, and version-specific notes, see the UPGRADE Guide.
Each framework uses different template engines. Here's a complete overview:
| Framework | Default Template Engine | Optional Engines | Formatter Available | |-----------|------------------------|------------------|---------------------| | Symfony | Twig | - | ✅ Twig-CS-Fixer | | Laravel | Blade | Twig (via twigbridge) | ✅ PHP-CS-Fixer (Blade), Twig-CS-Fixer (if Twig installed) | | Yii | PHP native views | Twig | ✅ Twig-CS-Fixer (if Twig installed) | | CakePHP | PHP native (.ctp) | Twig | ✅ Twig-CS-Fixer (if Twig installed) | | Laminas | PHP native | Twig, Smarty | ✅ Twig-CS-Fixer (if Twig installed) | | CodeIgniter | PHP native views | - | ❌ No formatter (PHP-CS-Fixer can format PHP code) | | Slim | PHP native | Twig | ✅ Twig-CS-Fixer (if Twig installed) |
The following template engines are used but don't have dedicated formatters yet:
CakePHP Templates (.ctp): PHP native template files
Can be partially formatted with PHP-CS-Fixer
Template-specific syntax may need manual review
Yii Views: PHP native template files
Can be partially formatted with PHP-CS-Fixer
Template-specific syntax may need manual review
CodeIgniter Views: PHP native template files
Can be partially formatted with PHP-CS-Fixer
Template-specific syntax may need manual review
Smarty Templates (.tpl): Used by Laminas and other frameworks
No dedicated formatter available
Future: May support Smarty-CS-Fixer or similar tool
Package detection: smarty/smarty
Note: PHP native template files can be formatted using PHP-CS-Fixer, but template-specific directives and syntax may require manual review.
The following template formatters are planned for future releases:
Smarty-CS-Fixer: For Smarty templates (.tpl files)
Will be automatically installed if smarty/smarty is detected
Framework support: Laminas, Generic
CakePHP Template Formatter: For CakePHP template files (.ctp)
Will be automatically installed if cakephp/cakephp is detected
Framework support: CakePHP
Yii View Formatter: For Yii PHP native views
Will be automatically installed if yiisoft/yii2 is detected
Framework support: Yii
CodeIgniter View Formatter: For CodeIgniter PHP native views
Will be automatically installed if codeigniter4/framework is detected
Framework support: CodeIgniter
Contributing: If you know of formatters for these template engines or would like to contribute support, please open an issue or pull request on GitHub.
PHP Quality Tools includes several custom rules for both Rector and PHP-CS-Fixer to improve code quality and formatting.
Rector Rules:
SplitLongGroupedImportsRector - Formats long grouped imports multilineSplitLongConstructorParametersRector - Splits long constructor parameters multilineAddMissingReturnTypeRector - Adds missing return types to public/protected methodsSplitLongMethodCallRector - Identifies long method call chains for multiline formattingPHP-CS-Fixer Fixers:
MultilineGroupedImportsFixer - Formats long grouped imports multilineMultilineArrayFixer - Formats long arrays multilineConsistentDocblockFixer - Ensures consistent docblock formattingSee docs/CUSTOM_RULES.md for details on how to use these rules and create your own.
Note: Custom Rector rules require an additional dependency: symplify/rule-doc-generator-contracts. Install it with:
composer require --dev symplify/rule-doc-generator-contracts
If you use the custom rules without this dependency, you'll see an informative message indicating what's missing.
For upgrade instructions, breaking changes, and troubleshooting, see docs/UPGRADING.md.
# Start the container
make up
# Install dependencies
make install
# Run tests
make test
# Run all QA checks
make qa
composer install
composer test
composer qa
The MIT License (MIT). Please see LICENSE for more information.
Please see docs/CONTRIBUTING.md for details.
For branching strategy, see docs/BRANCHING.md.
Please see docs/CHANGELOG.md for version history and compatibility information.
Created by Héctor Franco Aceituno at Nowo.tech