Unibeautify
  • Install
  • Docs
  • Assistant
  • Playground
  • GitHub

›Beautifiers

About

  • What is Unibeautify
  • Unibeautify CI
  • Credits

Usage

  • Getting Started
  • Command-Line Interface (CLI)
  • Configuration File
  • Language Options
  • Beautifier Options
  • Supported Languages
  • Editor Integration

Contributing

  • Examples

Integrations

  • GitHub
  • GitLab
  • Bitbucket

Beautifiers

  • Black
  • Brittany
  • ClangFormat
  • CSScomb
  • ESLint
  • Gofmt
  • JS-Beautify
  • PHP-CS-Fixer
  • PHP_CodeSniffer
  • Prettier
  • Pretty Diff
  • sqlformat
  • stylelint
  • TSLint
  • YAPF
Edit

PHP_CodeSniffer Beautifier

npm downloads GitHub Stars GitHub Issues Build Status

Edit PHP_CodeSniffer Beautifier

About

PHP_CodeSniffer beautifier for Unibeautify

PackageDocsLatest
@unibeautify/beautifier-php-codesnifferv0.1.2npm
unibeautifyv0.17.1npm

Prerequisites

Please install the following prerequisites.

PHPCBF executable

Build Status Code Consistency Gitter

PHPCBF executable is a third-party program you must install manually and is required for beautification. See https://github.com/squizlabs/PHP_CodeSniffer for more information. Install PHPCBF (phpcbf) by following https://github.com/squizlabs/PHP_CodeSniffer#installation. If you have questions or want to report a bug, go to https://github.com/squizlabs/PHP_CodeSniffer/issues.

Install

Install with npm:

npm install --save-dev unibeautify @unibeautify/beautifier-php-codesniffer

Or with yarn:

yarn add --dev unibeautify @unibeautify/beautifier-php-codesniffer

Usage

Add PHP_CodeSniffer to beautifiers language option. A .unibeautifyrc.json file would look like the following:

{
  "PHP": {
    "beautifiers": [
      "PHP_CodeSniffer"
    ]
  }
}

Advanced

The following beautifier option(s) are supported:

  • prefer_beautifier_config

See beautifier options docs for more information.

Example advanced configuration:

{
  "PHP": {
    "beautifiers": [
      "PHP_CodeSniffer"
    ],
    "PHP_CodeSniffer": {
      "prefer_beautifier_config": true,
      "PHPCBF": {
        "path": "/absolute/path/to/phpcbf"
      }
    }
  }
}

Options

No configuration options are supported. The following languages are supported without options: PHP.

FAQ

How to use PHP_CodeSniffer in Atom, VSCode, and other editors?

See the editor integration documentation for installation instructions for your editor of choice.

How to use PHP_CodeSniffer configuration file?

You can override Unibeautify configuration and use PHP_CodeSniffer's own configuration file instead with prefer_beautifier_config beautifier option.

{
  "LANGUAGE_NAME": {
    "beautifiers": [
      "PHP_CodeSniffer"
    ],
    "PHP_CodeSniffer": {
      "prefer_beautifier_config": "path/to/PHP_CodeSniffer/config/file"
    }
  }
}

See beautifier options docs for more information.

How to enable PHP_CodeSniffer to format on save?

See the editor integration documentation for format on save instructions for your editor of choice.

How to run PHP_CodeSniffer on all files?

You can run PHP_CodeSniffer on all of your files for every commit with Unibeautify CI.

Is there a PHP_CodeSniffer sandbox or playground?

You can quickly try PHP_CodeSniffer online with Unibeautify Playground.

Troubleshooting

Below are instructions for each of the supported Operating Systems.

Windows

Open the Command Prompt.

Show me how to open the Command Prompt.

Find the path to PHPCBF by running the command:

where phpcbf

Which will return an absolute path like one of the following:

C:\absolute\path\to\phpcbf
C:\absolute\path\to\phpcbf.exe
C:\absolute\path\to\phpcbf.bat

If where fails to return an executable path then you need to fix your PATH Environment Variable.

Show me how to change my PATH environment variable.

If you know the executable path go to the Configure section and replace /absolute/path/to/phpcbf with your specific executable path value.

macOS

Open the Terminal application.

Show me how to open the Terminal.

Find the path to PHPCBF by running the command:

which phpcbf

Which will return an absolute path like one of the following:

/absolute/path/to/phpcbf
/absolute/path/to/phpcbf.sh
/absolute/path/to/phpcbf.bash

If which fails to return an executable path then you need to fix your PATH Environment Variable:

Show me how to change my PATH environment variable.

If you know the executable path go to the Configure section and replace /absolute/path/to/phpcbf with your specific executable path value.

Linux

Open the Terminal application.

Show me how to open the Terminal.

Find the path to PHPCBF by running the command:

which phpcbf

Which will return an absolute path like one of the following:

/absolute/path/to/phpcbf
/absolute/path/to/phpcbf.sh
/absolute/path/to/phpcbf.bash

If which fails to return an executable path then you need to fix your PATH Environment Variable.

Show me how to change my PATH environment variable.

If you know the executable path go to the Configure section replace /absolute/path/to/phpcbf with your specific executable path value.

← PHP-CS-FixerPrettier →
  • About
  • Prerequisites
    • PHPCBF executable
  • Install
  • Usage
    • Advanced
  • Options
  • FAQ
    • How to use PHP_CodeSniffer in Atom, VSCode, and other editors?
    • How to use PHP_CodeSniffer configuration file?
    • How to enable PHP_CodeSniffer to format on save?
    • How to run PHP_CodeSniffer on all files?
    • Is there a PHP_CodeSniffer sandbox or playground?
  • Troubleshooting
    • Windows
    • macOS
    • Linux
Unibeautify
Docs
Getting StartedCLIConfigurationOptions
Community
User ShowcaseStack Overflow@Unibeautify on TwitterFollow Unibeautify on Twitter
More
GitHubStar Unibeautify on GitHubCode coverage of UnibeautifyCode coverage of Unibeautify
© 2020 Glavin Wiechert
Credits