← 返回命令列表

Linux command

php-cs-fixer 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Fix current directory

php-cs-fixer fix

Fix specific file

php-cs-fixer fix [file.php]

Dry run

php-cs-fixer fix --dry-run

Show diff

php-cs-fixer fix --diff

Use specific rule set

php-cs-fixer fix --rules=@PSR12

Fix with verbose output

php-cs-fixer fix -v

List files that need fixing

php-cs-fixer list-files

说明

PHP CS Fixer automatically fixes PHP code to follow coding standards. It supports PSR-1, PSR-2, PSR-12, Symfony, and custom rule sets. The tool parses PHP files, applies configured fixers, and rewrites files with corrected formatting.

参数

fix _PATH_
Fix coding standards in the given path or current directory.
check _PATH_
Shorthand for `fix --dry-run`. Analyze without modifying files.
--dry-run
Don't modify files, only show what would change.
--diff
Show a diff of applied changes.
--rules _RULES_
Coding standard rules or rule sets (e.g., @PSR12, @Symfony).
--config _FILE_
Path to configuration file.
--allow-risky _yes|no_
Allow risky rules that may change code behavior.
--using-cache _yes|no_
Enable or disable caching (default: yes).
--cache-file _FILE_
Path to cache file (default: .php-cs-fixer.cache).
--format _FORMAT_
Output format (txt, json, checkstyle, gitlab, junit, xml).
--stop-on-violation
Stop execution on first violation.
--path-mode _override|intersection_
How to treat paths from config vs command arguments (default: override).

FAQ

What is the php-cs-fixer command used for?

PHP CS Fixer automatically fixes PHP code to follow coding standards. It supports PSR-1, PSR-2, PSR-12, Symfony, and custom rule sets. The tool parses PHP files, applies configured fixers, and rewrites files with corrected formatting.

How do I run a basic php-cs-fixer example?

Run `php-cs-fixer fix` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does fix _PATH_ do in php-cs-fixer?

Fix coding standards in the given path or current directory.