devwolk/linters
Composer 安装命令:
composer require devwolk/linters
包简介
Centralized PHP linter configurations and static analysis tools for PHP projects
关键字:
README 文档
README
Centralized PHP linter configurations. Rules are bundled - you configure only paths.
Installation
composer require --dev devwolk/linters
Requirements: PHP 8.4+
Supported Tools
| Tool | Description |
|---|---|
| Rector | Auto-refactoring, PHP migrations |
| PHP-CS-Fixer | Code formatting (PSR-12) |
| PHPStan | Static analysis (level 8) |
| PHPCS | Code style (PSR-12 + Slevomat) |
| PHPCBF | Auto-fix PHPCS violations |
| PHPMD | Code quality detector |
| composer-unused | Unused dependencies |
| composer-normalize | Normalize composer.json |
Configuration
An example of the full composer.json configuration:
{
"extra": {
"linters": {
"rector": {
"paths": ["app", "database", "tests", "routes"],
"php-version": "8.4",
"skip-dirs": ["app/Http/Requests"],
"skip-files": ["app/Providers/AutoWireServiceProvider.php"],
"sets": [
"laravel12",
"phpunit12",
"doctrine"
],
"parallel": {
"enabled": true,
"files-per-process": 40,
"timeout": 360,
"max-processes": 2
},
"import-names": {
"import-names": true,
"import-doc-block-names": false,
"import-short-classes": false,
"remove-unused-imports": true
},
"cache-dir": ".cache/rector",
"memory-limit": "2048M"
},
"php-cs-fixer": {
"paths": ["app", "config", "database", "routes"],
"skip-dirs": ["bootstrap", "config", "docker", "public", "resources", "routes", "storage", "vendor"],
"skip-files": [],
"parallel": true,
"cache-dir": ".cache/php-cs-fixer"
},
"phpcs": {
"paths": ["app", "config", "database", "routes"],
"skip-dirs": ["vendor"],
"skip-files": ["tests/TestCase.php", "*\\.blade\\.php$"],
"parallel": 4,
"cache-dir": ".cache/phpcs",
"rule-excludes": {
"Generic.Metrics.CyclomaticComplexity.TooHigh": ["tests/*", "src/Utils/ConfigurationLoader.php"],
"Squiz.WhiteSpace.ScopeClosingBrace": ["tests/*", "src/Utils/ConfigurationLoader.php"]
}
}
}
}
}
Options
| Option | Type | Tools | Description |
|---|---|---|---|
paths |
string[] |
all* | Required. Directories to analyze |
php-version |
string |
rector | Target PHP version: 8.3, 8.4, 8.5 (default: 8.4) |
skip-dirs |
string[] |
all* | Directories to exclude |
skip-files |
string[] |
all* | File patterns to exclude |
parallel |
bool|int|object |
rector, php-cs-fixer, phpstan, phpcs | Parallel execution |
cache-dir |
string |
rector, php-cs-fixer, phpstan, phpcs | Cache directory |
baseline |
string |
phpstan, phpmd | Baseline file |
sets |
string[] |
rector | Rector sets: laravel11, laravel12, symfony, doctrine |
memory-limit |
string |
rector | Memory limit (e.g., 2048M, 4G) |
import-names |
object |
rector | Import names configuration (see below) |
rule-excludes |
object |
phpcs | Rule-specific exclude patterns (see below) |
named-filters |
string[] |
composer-unused | Packages to ignore |
*except composer-unused and composer-normalize
Rector Import Names
The import-names option controls how Rector handles use import statements:
{
"extra": {
"linters": {
"rector": {
"paths": ["src"],
"import-names": {
"import-names": true,
"import-doc-block-names": false,
"import-short-classes": false,
"remove-unused-imports": true
}
}
}
}
}
| Key | Type | Default | Description |
|---|---|---|---|
import-names |
bool |
true |
Add use imports for fully qualified class names |
import-doc-block-names |
bool |
false |
Add use imports for docblock type hints |
import-short-classes |
bool |
false |
Import short class names (e.g., DateTime) |
remove-unused-imports |
bool |
true |
Remove unused use imports |
All fields are optional. Omitted fields use their default values. If import-names is not specified at all, all defaults apply.
PHPCS Rule Excludes
The rule-excludes option allows you to exclude specific PHPCS rules for certain files or directories:
{
"extra": {
"linters": {
"phpcs": {
"paths": ["src", "tests"],
"rule-excludes": {
"Generic.Metrics.CyclomaticComplexity.TooHigh": ["tests/*", "src/Utils/ConfigurationLoader.php"],
"Squiz.WhiteSpace.ScopeClosingBrace": ["tests/*", "src/Utils/ConfigurationLoader.php"]
}
}
}
}
}
This generates XML rules like:
<rule ref="Generic.Metrics.CyclomaticComplexity.TooHigh"> <exclude-pattern>tests/*</exclude-pattern> <exclude-pattern>src/Utils/ConfigurationLoader.php</exclude-pattern> </rule>
To exclude a rule entirely, use * as the pattern:
{
"rule-excludes": {
"Squiz.WhiteSpace.ScopeClosingBrace": ["*"]
}
}
Usage
./vendor/bin/linters run rector ./vendor/bin/linters run php-cs-fixer ./vendor/bin/linters run phpstan ./vendor/bin/linters run phpcs ./vendor/bin/linters run phpcbf ./vendor/bin/linters run phpmd ./vendor/bin/linters run composer-unused ./vendor/bin/linters run composer-normalize
Extra arguments can be passed after --:
./vendor/bin/linters run rector -- --dry-run ./vendor/bin/linters run php-cs-fixer -- --dry-run --diff ./vendor/bin/linters run phpstan -- --generate-baseline
Architecture
src/
├── Console/Command/ CLI commands (run, generate)
├── Service/ ToolRunner orchestration
├── CommandBuilder/ Command builders (one per tool)
├── ConfigGenerator/ Config file generators
├── DTO/ Configuration DTOs
├── Enum/ Tool registry
└── Utils/ ConfigurationLoader, validation
Each tool has:
- ConfigGenerator — generates config files (phpstan.neon, phpcs.xml, etc.)
- CommandBuilder — builds CLI command with proper arguments
Rector for Laravel
Requires: composer require --dev driftingly/rector-laravel
Baseline
For legacy projects with many existing issues, generate a baseline to ignore them:
PHPStan:
./vendor/bin/linters run phpstan -- --generate-baseline
Then add to config: "baseline": "phpstan-baseline.neon"
PHPMD:
./vendor/bin/linters run phpmd -- --generate-baseline
Then add to config: "baseline": "phpmd.baseline.xml"
Examples
See examples/ for Laravel and Symfony configurations.
devwolk/linters 适用场景与选型建议
devwolk/linters 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「linter」 「phpcs」 「static-analysis」 「phpmd」 「php-cs-fixer」 「PHPStan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 devwolk/linters 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 devwolk/linters 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 devwolk/linters 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
Lot's of tools for git, file and static source code analysis.
CodeSniffer ruleset for the ZettaCMS coding standard
CodeSniffer ruleset for the Superbrave coding standard
Validate Blade templates for syntax errors, security issues, and best practices
An less opinionated version of Laravel Pint.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-06