LoginSignup
13
16

More than 5 years have passed since last update.

(Mac)VisualStudioCodeでPHP開発環境の構築

Posted at

参考サイト

インテリセンス

  • 拡張機能「PHP Intelephense」

コードフォーマット

  • 拡張機能「php cs fixer」

導入方法

基本的にVisual Studio CodeでPHPを整形するの通りだが、若干補足した手順を下記に記述する

  • vscodeに拡張機能「php cs fixer」をインストール
  • PHP CS Fixerをダウンロード
    • GithubDownloadよりダウンロード
    • ダウンロードしたphp-cs-fixer.pharを任意のフォルダに保存
      今回は ~/.vscode/php-cs-fixer-v2.phar (Macintosh HD⁩ ▸ ⁨ユーザ⁩ ▸ ⁨xxxxx ▸ ⁨.vscode)に保存
  • Visual Studio CodeでPHP CS Fixerの設定
    • shift+cmd+pでコマンドパレットを開き、
      json(open settings(json))と入力しenter
    • 下記を追記
"php-cs-fixer.executablePath": "~/.vscode/php-cs-fixer-v2.phar",
"php-cs-fixer.rules": "@PSR2",
"php-cs-fixer.formatHtml": true,
"php-cs-fixer.onsave": true,
  • 拡張子phpのファイルを保存した際に、整形されればOK

Docコメント入力補完

  • 拡張機能「PHP DocBlocker」
  • 使用方法は参考サイト参照

括弧の対を見やすく・・・

  • 拡張機能「Bracket Pair Colorizer」

.envファイルにシンタックスハイライト

  • 拡張機能「DotENV」

アイコンテーマ

  • 拡張機能から「Material Icon Theme」をファイルアイコンテーマに設定
13
16
2

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
13
16