Download the PHP package nowo-tech/php-quality-tools without Composer
On this page you can find all versions of the php package nowo-tech/php-quality-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nowo-tech/php-quality-tools
More information about nowo-tech/php-quality-tools
Files in nowo-tech/php-quality-tools
Package php-quality-tools
Short Description Pre-configured quality tools for PHP projects (Rector, PHP-CS-Fixer, Twig-CS-Fixer) with automatic framework detection, plus CI gate scripts (Clover coverage threshold, module boundaries, latest-release-tag deploy guard), a PHPUnit SQL query-budget trait, ParaTest per-process isolation helpers, profiler-based route query scaling and missing-translation test traits, front-end / docs gates (no inline SVG, Vite asset budgets, Markdown links) AI agent co-author trailer checks / hooks, and quiet-run / junit-failures / changed-tests helpers (short gate summaries, failed tests of a JUnit log, tests covering the changes).
License MIT
Homepage https://github.com/nowo-tech/PhpQualityTools
Informations about the package php-quality-tools
PHP Quality Tools
⭐ 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
Plus opt-in CI gates (since 1.2.0): vendor/bin/check-coverage-threshold, vendor/bin/check-module-boundaries
and a PHPUnit QueryBudgetTrait (SQL query budgets / N+1 scaling checks), and a deploy guard (since 1.3.0):
vendor/bin/assert-latest-tag (only the highest semver tag deploys), and ParaTest isolation helpers (since 1.5.0):
the pid_path Symfony env var processor and vendor/bin/clean-stale-pid-paths, and front-end / docs gates (since 1.6.0):
vendor/bin/check-no-inline-svg, vendor/bin/check-asset-budgets (Vite), vendor/bin/check-doc-links and a
php-worker-reset Makefile snippet, and quiet-run helpers (since 1.8.0): vendor/bin/quiet-run (full output in a
log, a short summary on screen), vendor/bin/junit-failures and vendor/bin/changed-tests.
This bundle is FrankenPHP worker mode friendly.
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.phpfiles for project-specific settings - ✅ PHP 8.2+ support
- ✅ PSR-12 and Symfony coding standards
- ✅ Gate scripts: Clover coverage threshold (statements + lines) and module boundaries (YAML map of modules and forbidden / allowed import edges)
- ✅ Release guard:
assert-latest-tagrefuses to deploy a tag that is not the highest semver release (no rollback when an old tag is pushed), with a$GITHUB_OUTPUTmode - ✅
Testing\QueryBudgetTrait:assertQueryBudget()/assertScalesWith()on top of a Doctrine DBAL 4 counting middleware - ✅ Parallel PHPUnit (ParaTest) isolation:
pid_pathenv var processor (one path per test process) andclean-stale-pid-paths(removes the paths of dead processes) - ✅ Since 1.7.0:
Testing\RouteQueryScalingTrait(route query budgets / N+1 scaling through the profiler'sdbcollector),Testing\MissingTranslationsTrait(profiler missing translations with an allowlist), andcheck-no-agent-coauthor/strip-agent-coauthor/install-git-hooks+git-hygiene.mk(no AI agent co-author trailers; POSIX sh) - ✅ Since 1.8.0:
quiet-run(a command's full output in a log,OK/FAILsummary with failed make targets, failed PHPUnit tests and the lines before the first error; real exit code),junit-failures(only the failed tests of a JUnit log) andchanged-tests(test files covering the changes since the last tag) - ✅ Front-end and docs gates: no inline SVG in templates / scripts, per-entry Vite JS / CSS size budgets (raw and gzip), broken relative Markdown links and images (optionally GitHub heading anchors), and a Docker Compose
php-worker-resetMakefile snippet
Installation
Automatic Dependency Installation
During installation, the plugin will:
- ✅ Detect your framework automatically
- ✅ Install configuration files for your framework
- ✅ Check for template engine dependencies (e.g., Twig for Twig-CS-Fixer)
- ✅ Install template formatter configs only if dependencies are present
- ✅ Check for suggested dependencies (Rector, PHP-CS-Fixer, etc.)
- ✅ Ask if you want to install them (in interactive mode)
Example output:
Note: If Twig is not installed, you'll see:
Then you may see:
Note: The optional packages (rector-symfony, rector-doctrine, rector-phpunit) are only suggested when Rector 1.x is installed. Rector 2.x bundles the Symfony, Doctrine and PHPUnit rule sets, so they are skipped when Rector 2.x is installed and when Rector is not installed yet (a fresh composer require rector/rector gets 2.x).
If you choose yes, dependencies will be installed automatically. If no, you can install them manually later.
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 suggested with constraints that target Rector 1.x
- For Rector 2.x or no Rector yet: Optional packages are skipped (Rector 2.x already bundles those rules)
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: Configuration installed automatically if
twig/twigis detected (works with Symfony, Laravel, Yii, CakePHP, Laminas, Slim, Generic) - Blade (Laravel): Formatted via PHP-CS-Fixer (
.blade.phpfiles 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
Rector
PHP-CS-Fixer
Template Formatters
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
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.
Note: Some Blade-specific directives (like @if, @foreach, etc.) may need manual review after formatting, as PHP-CS-Fixer treats them as PHP code.
Automatic Framework Detection
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.
Compatibility
| 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 |
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 6.0 - 6.4: ✅ Supported
- Symfony 7.0 - 7.4: ✅ Supported
- Symfony 8.0 - 8.1: ✅ Supported
Laravel Versions
- Laravel 9.0: ✅ Supported
- Laravel 10.0: ✅ Supported
- Laravel 11.0: ✅ Supported
Composer Scripts
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:
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 Twig templates without modifying them (same astwig:lint)
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 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.
Manual Scripts (Optional)
If you prefer different script names or commands, you can manually add them to your composer.json:
Using the Scripts
After enabling auto_add_scripts (or adding scripts manually), you can run:
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.
Gate Scripts and Query Budgets
Opt-in tools for CI; the Composer plugin does not call them.
See Quiet runs and focused test runs for the options, exit codes and make quiet / make test-changed recipes.
Customization
All customizations go in the *.custom.php files. These files are never overwritten.
Rector Customization
Edit .rector.custom.php:
PHP-CS-Fixer Customization
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:
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.
Twig-CS-Fixer Customization
Edit .twig-cs-fixer.custom.php:
Required Dependencies
This package provides configurations and can automatically install the required tools during installation.
Automatic Installation (Recommended)
The plugin will detect missing dependencies and offer to install them automatically. Just answer yes when prompted.
Manual Installation
If you prefer to install manually or the automatic installation didn't work:
Symfony Projects
Laravel Projects
Generic PHP Projects
Makefile Integration
Add to your Makefile:
CI Integration
GitHub Actions
Updating
When you update this package:
- ✅ Your custom files (
*.custom.php) are preserved - ✅ Main config files are NOT overwritten
- ✅ Missing main config files (
.rector.php,.php-cs-fixer.php, etc.) are created on bothcomposer installandcomposer updateif they do not exist yet - ✅ Missing dependencies will be detected and offered for installation (on update, only in interactive mode)
- ℹ️ Check the CHANGELOG for new features and compatibility updates
Important: 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:
For detailed upgrade instructions, breaking changes, and version-specific notes, see the UPGRADE Guide.
Template Engines by Framework
Each framework uses different template engines. Here's a complete overview:
Supported Template Formatters
| 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) |
Template Engines Without Dedicated Formatters
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.
Future Template Formatter Support
The following template formatters are planned for future releases:
-
Smarty-CS-Fixer: For Smarty templates (
.tplfiles)- Will be automatically installed if
smarty/smartyis detected - Framework support: Laminas, Generic
- Will be automatically installed if
-
CakePHP Template Formatter: For CakePHP template files (
.ctp)- Will be automatically installed if
cakephp/cakephpis detected - Framework support: CakePHP
- Will be automatically installed if
-
Yii View Formatter: For Yii PHP native views
- Will be automatically installed if
yiisoft/yii2is detected - Framework support: Yii
- Will be automatically installed if
- CodeIgniter View Formatter: For CodeIgniter PHP native views
- Will be automatically installed if
codeigniter4/frameworkis detected - Framework support: CodeIgniter
- Will be automatically installed if
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.
Custom Rules
PHP Quality Tools includes several custom rules for both Rector and PHP-CS-Fixer to improve code quality and formatting.
Included Custom Rules
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 formatting
PHP-CS-Fixer Fixers:
MultilineGroupedImportsFixer- Formats long grouped imports multilineMultilineArrayFixer- Formats long arrays multilineConsistentDocblockFixer- Ensures consistent docblock formatting
See 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:
If you use the custom rules without this dependency, you'll see an informative message indicating what's missing.
Upgrade Guide
For upgrade instructions, breaking changes, and troubleshooting, see docs/UPGRADING.md.
Development
Using Docker (Recommended)
Without Docker
Documentation
- GitHub Actions CI requirements
- Installation
- Configuration
- PSR evaluation (REQ-CS-007)
- Usage
- Contributing
- Code of Conduct
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
-
GitHub Spec Kit
Additional documentation
- Branching
- Custom Rules
Tests and coverage
- Tests: PHPUnit (PHP)
- PHP: 100.00%
- TS/JS: N/A
- Python: N/A
Justified exclusions (REQ-TEST-003): the @codeCoverageIgnore blocks in src/ only wrap branches the test
environment cannot reach — filesystem / file_get_contents failures in the Composer plugin (Plugin), defensive
returns in Rector / PHP-CS-Fixer rules for AST shapes the engines never hand over, and config value objects'
fallbacks for invalid YAML already rejected upstream. New markers need the same justification in review.
License
The MIT License (MIT). Please see LICENSE for more information.
Contributing
Please see docs/CONTRIBUTING.md for details.
For branching strategy, see docs/BRANCHING.md.
Changelog
Please see docs/CHANGELOG.md for version history and compatibility information.
Author
Created by Héctor Franco Aceituno at Nowo.tech
All versions of php-quality-tools with dependencies
composer-plugin-api Version ^2.0