在Windows 10下使用Joomla Standards

时间:2017-09-27 11:40:15

标签: php joomla sublimetext3 phpcs

我通过composer正确安装了所有内容,并将codesniff脚本路径添加到环境中。当我在命令行上运行它时:

phpcs --report=checkstyle --standard=Joomla -n C:\xampp\htdocs\myfile.php

我得到了正确的XML codesniff输出。

问题是我无法让它与Sublime 3一起运行。我安装了phpcs软件包并将其添加到用户设置中:

{
    "show_debug": true,
    "phpcs_additional_args": {
        "--standard": "Joomla",
        "-n": ""
    }
}

当我尝试嗅探文件时,我会在控制台中看到它:

[Phpcs] phpcs --report=checkstyle --standard=Joomla -n  C:\xampp\htdocs\myfile.php
[Phpcs] phpcs --report=checkstyle --standard=Joomla -n  C:\xampp\htdocs\myfile.php
[Phpcs] cwd:  C:\xampp\htdocs\myfile.php
Traceback (most recent call last):
  File "./python3.3/subprocess.py", line 1104, in _execute_child
FileNotFoundError: [WinError 2] System can't find the file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "phpcs in C:\Users\xxx\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 661, in run
  File "phpcs in C:\Users\xxx\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 479, in run
  File "phpcs in C:\Users\xxx\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 149, in get_errors
  File "phpcs in C:\Users\xxx\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 231, in execute
  File "phpcs in C:\Users\xxx\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 234, in parse_report
  File "phpcs in C:\Users\xxx\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 176, in shell_out
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1110, in _execute_child
FileNotFoundError: [WinError 2] System can't find the file

1 个答案:

答案 0 :(得分:0)

解决方案是:

  1. 虽然我有phpcs路径环境变量设置,我可以从任何地方调用phpcs命令,我必须将phpcs_executable_path设置为完整路径,如 "phpcs_executable_path": "c:\\Users\\xxx\\AppData\\Roaming\\Composer\\vendor\\squizlabs\\php_codesniffer\\scripts\\phpcs.bat"
    1. 我必须将--no-patch arg添加到phpcbf,因为在这样的vanilla窗口下没有diff命令存在
    2. "phpcbf_additional_args": { "--standard": "Joomla", "--no-patch": "", "-n": "" },

      1. 我必须编辑phpcs.bat文件并将@php_bin@替换为PHP可执行文件的完整路径。不知何故,在作曲家Prozess期间,那些应该被替换,但它没有发生: if "%PHPBIN%" == "" set PHPBIN=c:\xampp\php\php.exe
      2. 所以要做很多废话。在所有安装过程中,对我的窗口的接缝都没有得到很好的支持。