LoginSignup
2

More than 5 years have passed since last update.

Visual Studio Code でPSR-2規約チェックを入れようとした時の話

Posted at

1. vscode拡張機能で「phpcs」をインストール

2. ユーザー設定でJSONに以下を追加

"phpcs.standard": "PSR2"

3. エラーが起こる…

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.

4. MACにphp_codesnifferをインストール

phpとcomposerは入ってる前提で以下を実行

composer global require "squizlabs/php_codesniffer=*"
vi ~/.bash_profile
----
# テキストに以下を追加
export PATH=$PATH:$HOME/.composer/vendor/bin
----
source ~/.bash_profile

これで使えるようになりました。

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
2