PHPackages                             nowo-tech/php-quality-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. nowo-tech/php-quality-tools

ActiveComposer-plugin[Testing &amp; Quality](/categories/testing)

nowo-tech/php-quality-tools
===========================

Pre-configured quality tools for PHP projects (Rector, PHP-CS-Fixer, Twig-CS-Fixer). Symfony, Laravel, and framework-agnostic configurations with automatic framework detection.

v1.0.10(2mo ago)01.3k↓46.9%MITPHPPHP &gt;=8.1CI passing

Since Dec 11Pushed 1mo agoCompare

[ Source](https://github.com/nowo-tech/PhpQualityTools)[ Packagist](https://packagist.org/packages/nowo-tech/php-quality-tools)[ Docs](https://github.com/nowo-tech/PhpQualityTools)[ GitHub Sponsors](https://github.com/HecFranco)[ RSS](/packages/nowo-tech-php-quality-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (15)Used By (0)

PHP Quality Tools
=================

[](#php-quality-tools)

[![CI](https://github.com/nowo-tech/PhpQualityTools/actions/workflows/ci.yml/badge.svg)](https://github.com/nowo-tech/PhpQualityTools/actions/workflows/ci.yml) [![Packagist Version](https://camo.githubusercontent.com/8d4e65a8c24ef3d73d3ed0731aaf2d28d4dc8bd26e0bb5cd8fa1dd76ff29ca88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f776f2d746563682f7068702d7175616c6974792d746f6f6c732e7376673f7374796c653d666c6174)](https://packagist.org/packages/nowo-tech/php-quality-tools) [![Packagist Downloads](https://camo.githubusercontent.com/f240153b4b7e8c63f96b5701ae154eda89d8e2f771a6c34018dda1b51cdf2c7f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6f776f2d746563682f7068702d7175616c6974792d746f6f6c732e737667)](https://packagist.org/packages/nowo-tech/php-quality-tools) [![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE) [![PHP](https://camo.githubusercontent.com/8e58b490725ac49cc8e463c473173681b324c9d92d7854275a785db013ca3de7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242343f6c6f676f3d706870)](https://php.net) [![Symfony](https://camo.githubusercontent.com/8fe7de83f11ab7ca74742794be56f9291632c8351a9ae5baea0bc1e9c4eb5a35/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d3625323025374325323037253230253743253230382d3030303030303f6c6f676f3d73796d666f6e79)](https://symfony.com) [![GitHub stars](https://camo.githubusercontent.com/da226fa821ba93174497d68a934d68c2e78bae8433aa66df0f3950b37ca9597f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e6f776f2d746563682f7068702d7175616c6974792d746f6f6c732e7376673f7374796c653d736f6369616c266c6162656c3d53746172)](https://github.com/nowo-tech/PhpQualityTools) [![Coverage](https://camo.githubusercontent.com/ac5243a96a873b24cae2aa929ca482dbdd93c30a36763f1115522e131c7a6e5f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f7665726167652d3130302e30302532352d627269676874677265656e)](#tests-and-coverage)

> ⭐ **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:

- **Rector** - Automated code refactoring
- **PHP-CS-Fixer** - Code style fixing (PSR-12 + Symfony)
- **Twig-CS-Fixer** - Twig template style fixing

Automatic Framework Detection
-----------------------------

[](#automatic-framework-detection)

The package **automatically detects** your framework and installs the appropriate configuration:

FrameworkDetectionRectorPHP-CS-FixerTemplate EngineTemplate 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`.

Compatibility
-------------

[](#compatibility)

VersionPHPSymfonyLaravelComposer**1.0.x** (1.0.0 – 1.0.10)&gt;= 8.16.0 - 7.49.0 - 11.0&gt;= 2.0### PHP Versions

[](#php-versions)

- **PHP 8.1**: ✅ Fully supported
- **PHP 8.2**: ✅ Fully supported
- **PHP 8.3**: ✅ Fully supported
- **PHP 8.4**: ✅ Fully supported
- **PHP 8.5**: ✅ Fully supported

### Symfony Versions

[](#symfony-versions)

- **Symfony 6.0 - 6.4**: ✅ Supported
- **Symfony 7.0 - 7.4**: ✅ Supported

### Laravel Versions

[](#laravel-versions)

- **Laravel 9.0**: ✅ Supported
- **Laravel 10.0**: ✅ Supported
- **Laravel 11.0**: ✅ Supported

Features
--------

[](#features)

- ✅ **Automatic framework detection** during installation
- ✅ **Automatic dependency installation** (Rector, PHP-CS-Fixer, etc.)
- ✅ Framework-specific configurations (Symfony, Laravel)
- ✅ Customizable without losing base settings
- ✅ Files are **NEVER overwritten** after first install
- ✅ Separate `*.custom.php` files for project-specific settings
- ✅ PHP 8.1+ support
- ✅ PSR-12 and Symfony coding standards

Installation
------------

[](#installation)

```
composer require --dev nowo-tech/php-quality-tools
```

### Automatic Dependency Installation

[](#automatic-dependency-installation)

During installation, the plugin will:

1. ✅ **Detect your framework** automatically
2. ✅ **Install configuration files** for your framework
3. ✅ **Check for template engine dependencies** (e.g., Twig for Twig-CS-Fixer)
4. ✅ **Install template formatter configs only if dependencies are present**
5. ✅ **Check for suggested dependencies** (Rector, PHP-CS-Fixer, etc.)
6. ✅ **Ask if you want to install them** (in interactive mode)

**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.

### Manual Installation

[](#manual-installation)

If you prefer to install dependencies manually or in non-interactive mode:

**Note**: The plugin automatically detects your Rector version:

- **For Rector 1.x**: Optional packages are installed normally
- **For Rector 2.x**: Optional packages are automatically skipped (not compatible yet)

```
# 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:

FilePurposeOverwritten 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**: Configuration installed automatically if `twig/twig` is detected (works with Symfony, Laravel, Yii, CakePHP, Laminas, Slim, Generic)
- **Blade (Laravel)**: Formatted via PHP-CS-Fixer (`.blade.php` files included automatically)
- **PHP Native Views** (Yii, CakePHP, CodeIgniter): Can be partially formatted with PHP-CS-Fixer, but template-specific syntax may need manual review
- **Smarty** (Laminas): No dedicated formatter available yet
- **CakePHP Templates (.ctp)**: No dedicated formatter available yet

Quick Start
-----------

[](#quick-start)

### Rector

[](#rector)

```
# Preview changes
./vendor/bin/rector process --dry-run

# Apply changes
./vendor/bin/rector process
```

### PHP-CS-Fixer

[](#php-cs-fixer)

```
# Preview changes
./vendor/bin/php-cs-fixer fix --dry-run --diff

# Apply changes
./vendor/bin/php-cs-fixer fix
```

### Template Formatters

[](#template-formatters)

#### Twig-CS-Fixer (All frameworks with Twig)

[](#twig-cs-fixer-all-frameworks-with-twig)

**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/
```

#### Blade Templates (Laravel)

[](#blade-templates-laravel)

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.

Composer Scripts
----------------

[](#composer-scripts)

**✨ Automatic Installation**: The plugin automatically adds Composer scripts to your `composer.json` during installation. You don't need to add them manually!

The following scripts are automatically 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-Fixer
- `rector:check` - Preview Rector changes (dry-run)
- `rector` - Apply Rector changes
- `test` - Run PHPUnit tests (if phpunit is installed)

**If Twig is installed:**

- `twig:lint` - Lint Twig templates (dry-run)
- `twig:fix` - Fix Twig templates
- `twig:fix:check` - Check and fix Twig templates

**Laravel only:**

- `blade-check` - Check Blade templates (dry-run)
- `blade-fix` - Fix Blade templates

**Note**: Existing scripts in your `composer.json` are never overwritten. The plugin only adds missing scripts.

**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.

### Manual Scripts (Optional)

[](#manual-scripts-optional)

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"
 }
}
```

### Using the Scripts

[](#using-the-scripts)

After installation, you can run the automatically installed scripts:

```
# 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**: The scripts above are automatically added by the plugin. If you prefer different script names or commands, you can manually add them to your `composer.json` (see "Manual Scripts" section above).

Customization
-------------

[](#customization)

All customizations go in the `*.custom.php` files. These files are never overwritten.

### Rector Customization

[](#rector-customization)

Edit `.rector.custom.php`:

```
