2

Sublime Text 3 用の PHPCS プラグインをインストールし、次のようにユーザー構成ファイルをセットアップしました。

{

// Path to php on windows installation
// This is needed as we cannot run phars on windows, so we run it through php
"phpcs_php_prefix_path": "C:\\wamp\bin\\php\\php5.4.12\\php.exe",

// This is the path to the bat file when we installed PHP_CodeSniffer
"phpcs_executable_path": "C:\\wamp\\bin\\php\\php5.4.12\\phpcs.bat",

// PHP-CS-Fixer settings
// Don't want to auto fix issue with php-cs-fixer
"php_cs_fixer_on_save": false,

// Show the quick panel
"php_cs_fixer_show_quick_panel": true,

// The fixer phar file is stored here:
"php_cs_fixer_executable_path": "C:\\wamp\bin\\php\\php5.4.12\\php-cs-fixer.phar",

// PHP Linter settings
// Yes, lets lint the files
"phpcs_linter_run": true,

// And execute that on each file when saved (php only as per extensions_to_execute)
"phpcs_linter_command_on_save": true,

// Path to php
"phpcs_php_path": "C:\\wamp\bin\\php\\php5.4.12\\php.exe",

// This is the regex format of the errors
"phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",


// PHP Mess Detector settings
// Not turning on the mess detector here
"phpmd_run": false,
"phpmd_command_on_save": false,
"phpmd_executable_path": "",
"phpmd_additional_args": {}
}

PHP ファイルをスニッフィングしようとすると、「FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません」というエラーが表示されます。

パスを再確認しましたが、それらは正しいです。Sublime がデフォルトの構成ファイルのみを読み取り、ユーザー構成ファイルを読み取っていない可能性はありますか?

編集 - パスに 2 番目のバックスラッシュがありませんでした。申し訳ありませんが、スニファーは現在動作しています。

4

1 に答える 1

4

指示を読まずに試してみたところ、解決策が見つかりました。次の手順を試してください。

  • ST3 の Package Control から php コード スニファー アドオンをダウンロードします。
  • この Web サイトから php-cs-fixer ファイルをダウンロードします => cs.sensiolabs.org/ (直接リンク => cs.sensiolabs.org/get/php-cs-fixer.phar)
  • ダウンロードしたファイルを php.exe ディレクトリにコピーします (私の場合は C:/XAMMP/php/php.exe です)
  • このページから PHP_CodeSniffer PEAR コード パッケージをダウンロードします
  • PHP_CodeSniffer-1.5.0RC4.tgz\PHP_CodeSniffer-1.5.0RC4\scripts\phpcs.bat を見つけて、このファイルも (php.exe ディレクトリに) コピーします。
  • 最初の投稿の構成ファイルをコピーし、[パッケージ設定] -> [Php コード スニファー] -> [設定] - [ユーザー ファイル] に書き込みながら、それに応じてディレクトリを変更します。この方法は、Win8 x64 システムの Sublime Text 3 Build 3047 で機能しました...遅い ST2 はもうありません...乾杯
于 2013-10-17T08:54:51.890 に答える