LoginSignup
1
0

More than 5 years have passed since last update.

composer の global インストールしたコマンドの実行(phpcsとか)の準備

Posted at

VScode を使って、php のコーディングをしているんですが、ある日

phpcs: Request workspace/configuration failed with message: Unable to locate phpcs. Please add phpcs to your global path or use composer dependency manager to install it in your project locally.

とメッセージが出て、phpcs が使用できなくなりました^^;
*というより、しばらく使っていなかったら、いつの間にか使えなくなっていましたw

解消方法

エラーメッセージを読めばわかるのですが、原因は global にインストールしたコマンドに path が通ってないだけです。

以下のコマンドで、global 導入先を確認

composer global config bin-dir --absolute
or
php composer.phar global config bin-dir --absolute

path の設定に関して、Windows7 での方法ですが補足しておきます。

環境変数$PATHに上記で確認したディレクトリを登録
C:\Users\hogehoge\AppData\Roaming\Composer/vendor/bin
サンプルのように、後半のディレクトリ指定がスラッシュで表記されているので、ちゃんとバックスラッシュに変更して登録してください。
C:\Users\hogehoge\AppData\Roaming\Composer\vendor\bin

これで解消されます。

余談

発生原因を追いかけるつもりは無いですけど、上記で解消されたため、むしろ「なんで今まで動いていたんだろう」って疑問がw
特になにかしたわけでもなかったので、もし原因がなんらかのアップデート絡みであれば情報共有するとだれかの役に立つかもと思い、記事を作成しました。

1
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
1
0