0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PhpStorm(Windows)にCodeSnifferを追加してPSR-12のチェックをしたい

Last updated at Posted at 2020-09-14

目的

PhpStormでPSR-12に準拠したコーディング規約のチェックを行いたい。

前提条件

  • Windows環境
  • PHP導入済(XAMPP)
  • Composer導入済

設定手順

ComposerでCodeSnifferをインストール

$ composer global require squizlabs/php_codesniffer

# インストールができたらバージョン情報を表示して動作するか確認
$ phpcs --version
PHP_CodeSniffer version 〇.〇.〇 (stable) by Squiz (http://www.squiz.net)

PhpStomの設定を変更

  1. PhpStomの[ファイル] -> [設定] を開く

  2. [言語 & フレームワーク] -> [PHP] -> [品質ツール] -> [PHP_CodeSniffer]を開く。
    ss1.png

  3. [...]ボタンをクリックし、[PHP_CodeSniffer path] にphpcs.batと入力。

  4. [検証]ボタンを押して
    OK, PHP_CodeSniffer version 〇.〇.〇 (stable) by Squiz (http://www.squiz.net)
    と出るか確認。
    ss2.png

  5. [エディター] -> [インスペクション] -> [品質ツール] -> [PHP_CodeSniffer validation]を開く。

  6. [Coding standard]に「PSR12」を選択する。
    ss3.png

  7. [OK]ボタンを押して完了

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?