在Sublime Text 3中,我通过Package Manager安装了以下软件包:
问题是,phpmd和phpcs都不起作用。当在php中打开ST3文件时,然后单击:ctrl和‘I获得以下调试信息:
SublimeLinter: debug mode: on
SublimeLinter: temp directory: c:\users\alekspav\appdata\local\temp\SublimeLinter3-alekspav
SublimeLinter: annotations activated: <builtin>
SublimeLinter: json activated: <builtin>
SublimeLinter: WARNING: phpcs deactivated, cannot locate 'phpcs'
SublimeLinter: annotations activated: <builtin>
SublimeLinter: WARNING: jshint deactivated, cannot locate 'jshint'
SublimeLinter: php activated: C:\xampp\php\php.exe
SublimeLinter: WARNING: phpmd deactivated, cannot locate 'phpmd'
SublimeLinter: WARNING: htmltidy deactivated, cannot locate 'tidy'
SublimeLinter: WARNING: csslint deactivated, cannot locate 'csslint'
SublimeLinter: php: submitter.php ['C:\\xampp\\php\\php.exe', '-l', '-n', '-d', 'display_errors=On', '-d', 'log_errors=Off']
SublimeLinter: php output:
No syntax errors detected in - 我对这两行特别感兴趣:
我试图解决这个问题的方法是编辑用户配置文件:Sublime text 3: Preferences -> package settings -> sublime linter-> settings - user。
然后添加cmd密钥如下:
"phpcs": {
"@disable": false,
"args": [],
"cmd": "C:/xampp/htdocs/web/vendor/bin/phpcs/",
"excludes": [],
"standard": "PSR2"
},
"phpmd": {
"@disable": false,
"args": [],
"cmd": "C:/xampp/htdocs/web/vendor/bin/phpmd/",
"excludes": [],
"rulesets": "cleancode,codesize,controversial,design,naming,unusedcode"
}正如你已经猜到的--这并没有解决问题。我还尝试在没有/结束时编写路径,并尝试使用\de示波器代替/。我还试图直接指定PFAM文件。还尝试使用${project}变量,而不是使用整个C:/ path。在ST3重新启动后,我仍然收到警告。
我的另一个问题是-如何在调试窗口中输出"${project}“目录?因为我不确定它的设置是否正确,所以我想测试它。
更多信息:
崇高的项目目录是:C:\xampp\htdocs\web\test.sublime-project
下面是phpmd和phpcs的安装:
编辑:
好像我做错了。我在项目目录中添加了一个composer.json,内容如下:
{
"require-dev": {
"squizlabs/php_codesniffer": "2.*",
"phpmd/phpmd" : "@stable",
"mongodb/mongodb" : "@dev"
}
}在使用composer install命令安装所有内容之后-我创建了vendor文件夹,里面有很多目录,包括bin文件夹。它现在有所有必要的文件,但我仍然得到同样的错误。由于某种原因无法找到模块。
发布于 2016-09-05 15:00:14
好吧,
我不确定是bug还是特性,但我找到了问题的解决方案。
phpcs和phpmd安装pear!没有这个-你会看到警告从最初的帖子。pear安装PHP_CodeSniffer phpmd:这里的说明:http://pear.phpmd.org/ (我不记得另一个存储库的名称,但在第一次安装过程中,您将遇到一些库丢失的错误,并将提示您添加另一个存储库,该存储库缺少对phpmd pear安装的依赖关系。一切都很容易)
启动ST3并检查。配置中不需要编辑。这两个模块都应该在Sublime Text 3中工作!但是我们现在使用的是pear模块,而不是composer模块。我最初的想法是使用conmposer。这是更容易的人和更新。
如果你对它不熟悉的话--谷歌。在项目目录中,应该有一个名为composer.json的文件,其内容类似于:
{
"require-dev": {
"squizlabs/php_codesniffer": "2.*",
"phpmd/phpmd" : "@stable"
}
}然后使用Windows command prompt和composer install命令安装所有模块
SublimeLinter的intiail post用户配置中嵌入的配置使用以下配置:
"phpcs":{ "@disable":false,"args":[],"cmd":“${project}/供应商/bin/phpcs.bat”,“排除”:[],“标准”:"${project}/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/ruleset.xml“},"phpmd":{ "@disable":false,"args":[],"cmd":“${project}/供应商/bin/phpmd.bat”,“排除”:[],“规则集”:“清洁代码、代码大小、争议性、设计、命名、无用代码”}现在重新启动Sublime test 3并打开调试和打开PHP文件。结果是:
reloading plugin SublimeLinter-phpcs.linter
SublimeLinter: phpcs linter loaded
reloading plugin SublimeLinter-phpmd.linter
SublimeLinter: phpmd linter loaded
...
reloading settings Packages/User/SublimeLinter.sublime-settings
SublimeLinter: phpcs activated: C:\xampp\php\phpcs.bat
SublimeLinter: phpmd activated: C:\xampp\php\phpmd.bat
...
SublimeLinter: phpcs: index.php ['C:/xampp/htdocs/web/vendor/bin/phpcs.bat', '--report=checkstyle', '--standard=C:/xampp/htdocs/web/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/ruleset.xml']
SublimeLinter: phpcs output:
.. errors in PHP file listed
Package Control: Skipping automatic upgrade, last run at 2016-09-05 17:12:20, next run at 2016-09-05 18:12:20 or after
...
SublimeLinter: phpmd: index.php ['C:/xampp/htdocs/web/vendor/bin/phpmd.bat', '@', 'text', 'cleancode,codesize,controversial,design,naming,unusedcode']
SublimeLinter: phpmd output:
.. errors in PHP file listed如您所见- SublimeLinter首先在PHP目录中加载pear bat!但是当提交PHP文件进行分析时--它使用的是项目目录中的新bat。
我的解释是,SublimeLinter总是需要安装pear phpcs和phpmd,然后才能使用composer等价物。如果你问我..。但我找不到其他解决办法了。
发布于 2017-06-15 10:02:04
我也很难找到一份工作。下面是我修复的方法:
假设:
步骤:
对我来说,这是因为我错过了第二步,这样phpmd linter就不能工作了。
没有必要使用composer安装每个项目的phpmd。安装后不需要手动修改SublimeLinter的设置。
希望这个能帮上忙。
https://stackoverflow.com/questions/39291264
复制相似问题