Sublime Text 3 Sublimelinter phplint 和 php 找不到?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20635043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:21:43  来源:igfitidea点击:

Sublime Text 3 Sublimelinter phplint and php not found?

phpsublimetext3lintsublimelinter

提问by Andy

I have been playing with this for over an hour to get the sublimelinter working.

我已经玩了一个多小时来让 sublimelinter 工作。

So I now have the following packages installed:

所以我现在安装了以下软件包:

  • SublimeLinter
  • SublimeLinter-php
  • SublimeLinter-phplint
  • SublimeLinter
  • SublimeLinter-php
  • SublimeLinter-phplint

Does someone know why it still does not lint the PHP I write?

有人知道为什么它仍然没有对我编写的 PHP 进行 lint 处理吗?

I am working on Windows and cannot find any docs relating to sublime 3 and windows.

我在 Windows 上工作,找不到任何与 sublime 3 和 windows 相关的文档。

The console reads:

控制台显示:

SublimeLinter: cannot locate 'phplint' 

SublimeLinter: cannot locate 'php'

回答by jmk

I had the same problem and FINALLY figured out, how to get SublimeLinter to work in SublimeText 3. After installing SublimeLinterand SublimeLinter-phpit kept telling me SublimeLinter: cannot locate 'php'. (No surprise, PHP isn't in my PATHon purpose).

我有同样的问题,终于想通了,如何让SublimeLinter工作在SublimeText 3.安装完成后SublimeLinterSublimeLinter-php它不停地告诉我SublimeLinter: cannot locate 'php'。(毫不奇怪,PHP 不是我PATH故意的)。

After adding the path of my PHP installation to the SublimeLinter User Settings (Preferences -> Package Settings -> SublimeLinter -> Settings - User), and a restart of SublimeText everything is working as expected now.

将我的 PHP 安装路径添加到 SublimeLinter 用户设置(首选项 -> 包设置 -> SublimeLinter -> 设置 - 用户)并重新启动 SublimeText 后,一切都按预期工作。

Here is the relevant part:

这是相关部分:

"paths": {
    "linux": [],
    "osx": [],
    "windows": [
        "C:/Program Files (x86)/PHP/php-5.4/"
    ]
},

I didn't have to change anything else.

我不必更改任何其他内容。

回答by Erwan

I encountered the same issue on Windows with the SublimeLinter-phpindependent linter plugin for the widely rewritten SublimeLinter 3:

我在 Windows 上遇到了同样的问题,使用SublimeLinter-php独立的linter插件,用于广泛重写的SublimeLinter 3

WARNING: php deactivated, cannot locate 'php'

警告:php 已停用,找不到“php”

I solved it too by just adding the relevant PATH(with double backslashes!) in SublimeLinter 3 "extra pathes" user setting (vs. other method/choice i.e. directly editing the Windows PATHenvironment variable), so that the executable's directoryis available to SublimeLinter:

我也通过PATH在 SublimeLinter 3“额外路径”用户设置(与其他方法/选择,即直接编辑 WindowsPATH环境变量)中添加相关(带双反斜杠!)来解决它,以便SublimeLinter 可以使用可执行文件的目录

"paths": {
    "linux": [],
    "osx": [],
    "windows": [
    "C:\xampplite\php\"
    ]
}

It's really worth noting that you must provide the directory that will be searched, not the direct path to the executable; it took me a while to figure this out, since the corresponding SublimeLinter setting in Sublime Text 2 must on the contrary include the executable; in my case:

值得注意的是,您必须提供将要搜索的目录,而不是可执行文件的直接路径;我花了一段时间才弄清楚这一点,因为 Sublime Text 2 中相应的 SublimeLinter 设置必须相反地包含可执行文件;就我而言:

"sublimelinter_executable_map":
{
    "php": "C:\xampplite\php\php.exe"
}

回答by Robert Went

I was struggling with this as well but just got it working. You need to install phplint which you can download from http://www.icosaedro.it/phplint/download.html

我也在努力解决这个问题,但刚刚让它工作。您需要安装 phplint,您可以从http://www.icosaedro.it/phplint/download.html下载

Open up the zip and copy phplint.exe and phpl.bat to your php directory (mine is c:/wamp/bin/php/php5.3.13/)

打开 zip 并将 phplint.exe 和 phpl.bat 复制到您的 php 目录(我的是 c:/wamp/bin/php/php5.3.13/)

You also need to have the path to php in your windows path which you can find by right clicking on 'my computer' and properties -> advanced system settings -> environment variables -> system variables -> path Add the path on the end separated by a ; mine was as above C:\wamp\bin\php\php5.3.13 if you want to use node for js hinting then add the path to node here as well.

您还需要在 Windows 路径中包含 php 的路径,您可以通过右键单击“我的电脑”和属性 -> 高级系统设置 -> 环境变量 -> 系统变量 -> 路径在末尾添加路径分隔由 ; 我的和上面一样 C:\wamp\bin\php\php5.3.13 如果你想使用 node 进行 js 提示,那么也在这里添加 node 的路径。

I think the linters now get added automatically but you can check in the file:

我认为 linter 现在会自动添加,但您可以签入文件:

Preferences -> Package Settings -> SublimeLinter -> Settings - User

首选项 -> 包设置 -> SublimeLinter -> 设置 - 用户

Mine looks like this (the relevant parts. If the file is blank copy the contents of the default settings file)

我的看起来像这样(相关部分。如果文件为空白,则复制默认设置文件的内容)

"lint_mode": "background",
    "linters": {
        "csslint": {
            "@disable": false,
            "args": [],
            "errors": "",
            "excludes": [],
            "ignore": "",
            "warnings": ""
        },
        "htmltidy": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "jshint": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "php": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "phplint": {
            "@disable": false,
            "args": [],
            "excludes": []
        }
    },
    "mark_style": "outline",

If you then restart it should start linting.

如果您然后重新启动它应该开始linting。

回答by Moh .S

step 1: Find out the location of php executable (use cmd 'which php' on linux) => "/usr/bin/php" step 2: Edit the Subimelinter package's user settings with the following steps.
step 3: Edit the linters object related to php with this "linters": { "php": { "@disable": false, "args": [], "cmd": "/usr/bin/php", "excludes": [] } },

第 1 步:找出 php 可执行文件的位置(在 linux 上使用 cmd 'which php')=> "/usr/bin/php" 第 2 步:使用以下步骤编辑 Subimelinter 包的用户设置。
第 3 步:使用此编辑与 php 相关的 linters 对象"linters": { "php": { "@disable": false, "args": [], "cmd": "/usr/bin/php", "excludes": [] } },

step 4: Make sure the syntax_map object has "php": "php" like this "syntax_map": { "html (django)": "html", "html (rails)": "html", "html 5": "html", "javascript (babel)": "javascript", "javascript (dom)": "javascript", "magicpython": "python", "php": "php", "python django": "python", "pythonimproved": "python" },

第 4 步:确保syntax_map 对象有这样的"php":"php""syntax_map": { "html (django)": "html", "html (rails)": "html", "html 5": "html", "javascript (babel)": "javascript", "javascript (dom)": "javascript", "magicpython": "python", "php": "php", "python django": "python", "pythonimproved": "python" },

Note: Before following all these steps make sure that you have installed both sublimeter, and sublimelinter-php packages.

注意:在执行所有这些步骤之前,请确保您已经安装了 sublimeter 和 sublimelinter-php 包。

回答by Andy

I ended up reading the entire documentation and found that during install the links provided where quite substantial and it had only been due to my speed of reading I had not seen all the information I have needed.

我最终阅读了整个文档,发现在安装过程中提供的链接相当丰富,这只是由于我的阅读速度,我没有看到我需要的所有信息。

For future reference I used: Find a suitable linter: https://github.com/SublimeLinter

为了将来参考,我使用了:找到合适的 linter:https: //github.com/SublimeLinter

To fix lint issues: http://sublimelinter.readthedocs.org/en/latest/troubleshooting.html#debugging-path-problems

修复 lint 问题:http: //sublimelinter.readthedocs.org/en/latest/troubleshooting.html#debugging-path-problems

For PHP lib: http://windows.php.net/download/

对于 PHP 库:http: //windows.php.net/download/

Path Editor (I went down this route): http://patheditor2.codeplex.com/

路径编辑器(我走这条路):http: //patheditor2.codeplex.com/

回答by MattDMo

SublimeLinter3 was just released, and is a complete rewrite of the old version. I haven't had a chance to completely parse them yet, but the new docs are located here. I'd urge you to read through them completely, as the architecture has changed dramatically, and the settings are quite different from before.

SublimeLinter3 刚刚发布,是对旧版本的完全重写。我还没有机会完全解析它们,但新文档位于此处。我强烈建议您通读一遍,因为架构发生了巨大变化,而且设置与以前大不相同。