Forrest logo
tool overview
On this page you find all important commands for the CLI tool phpcs. If the command you are looking for is missing please ask our AI.

phpcs

PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.

List of commands for phpcs:

  • php-codesniffer:standards:installed Display a list of installed coding standards.
    $ phpcs -i
    try on your machine
    explain this command
  • phpcs:tldr:0c46d phpcs: Don't recurse into subdirectories.
    $ phpcs ${path-to-directory} -l
    try on your machine
    explain this command
  • phpcs:tldr:20d8e phpcs: A comma-separated list of files to load before processing.
    $ phpcs ${path-to-directory} --bootstrap ${file(s)}
    try on your machine
    explain this command
  • phpcs:tldr:3891e phpcs: Sniff the specified directory for issues (defaults to the PEAR standard).
    $ phpcs ${path-to-directory}
    try on your machine
    explain this command
  • phpcs:tldr:79ff4 phpcs: Specify a coding standard to validate against.
    $ phpcs ${path-to-directory} --standard ${standard}
    try on your machine
    explain this command
  • phpcs:tldr:86493 phpcs: Specify the format of the output report (e.g. `full`, `xml`, `json`, `summary`).
    $ phpcs ${path-to-directory} --report ${format}
    try on your machine
    explain this command
  • phpcs:tldr:c4ba6 phpcs: Specify comma-separated file extensions to include when sniffing.
    $ phpcs ${path-to-directory} --extensions ${file_extension(s)}
    try on your machine
    explain this command
  • phpcs:tldr:f431e phpcs: Set config variables to be used during the process.
    $ phpcs ${path-to-directory} --config-set ${key} ${value}
    try on your machine
    explain this command
tool overview