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

phpcbf

PHP Code Beautifier and Fixer (PHPCBF) is a powerful command-line tool that automatically formats and fixes PHP code according to predefined coding standards. It is built on top of PHP_CodeSniffer, which is another popular tool for detecting and fixing coding standard violations in PHP code.

PHPCBF analyzes PHP files and applies a set of rules to automatically correct coding issues like indentation, whitespace, line breaks, and more. It provides a standardized and consistent approach to formatting PHP code, making it easier to read and understand.

It supports a wide range of coding standards, including PSR-1, PSR-2, PSR-12, Symfony, Zend, and more, making it highly flexible and customizable. The tool allows you to specify the coding standard you want to apply, or you can use a custom ruleset tailored to your specific needs.

PHPCBF is designed to be easy-to-use and integrates seamlessly with most code editors, build systems, and Continuous Integration (CI) platforms. It can be integrated into your development workflow, automatically formatting and fixing code issues as you write or commit PHP code.

Additionally, PHPCBF provides various command-line options and flags to control its behavior, such as fixing only specific files or directories, ignoring certain coding standard rules, or showing a summary of the changes made.

This tool not only helps maintain consistent code style across different PHP projects but also saves time by automating the process of manually fixing code formatting issues. It ensures that your code adheres to the specified coding standard, improving code readability, maintainability, and overall quality.

List of commands for phpcbf:

  • php:qa:cleanup:imports How to remove unused imports in php files?
    $ phpcbf --standard=PSR12 ${filename}
    try on your machine
    explain this command
  • phpcbf:tldr:0c19f phpcbf: Display a list of installed coding standards.
    $ phpcbf -i
    try on your machine
    explain this command
  • phpcbf:tldr:2e882 phpcbf: Specify a coding standard to validate against.
    $ phpcbf ${path-to-directory} --standard ${standard}
    try on your machine
    explain this command
  • phpcbf:tldr:4ecee phpcbf: Don't recurse into subdirectories.
    $ phpcbf ${path-to-directory} -l
    try on your machine
    explain this command
  • phpcbf:tldr:6e0d9 phpcbf: Specify comma-separated file extensions to include when sniffing.
    $ phpcbf ${path-to-directory} --extensions ${file_extension(s)}
    try on your machine
    explain this command
  • phpcbf:tldr:8f7d6 phpcbf: Fix issues in the specified directory (defaults to the PEAR standard).
    $ phpcbf ${path-to-directory}
    try on your machine
    explain this command
  • phpcbf:tldr:f2403 phpcbf: A comma-separated list of files to load before processing.
    $ phpcbf ${path-to-directory} --bootstrap ${file(s)}
    try on your machine
    explain this command
tool overview