SublimeLinter: PHP linting not working

2019-04-18 03:09发布

PHP linting is not working in SublimeLinter though it says PHP: loaded in the console. I'm working on Windows. Additionally, there are no options if I open the Command Palette except for Extract Annotations. Did anyone have the same problem and knows the solution?

8条回答
做个烂人
2楼-- · 2019-04-18 03:30

Additionally, make sure you've given the path to php.exe in your user settings -

  • (prefs>pkg settings>sublimelinter>settings - user)

  • should look like this (if your path is "C:\xampp\php\php.exe"):

{ "sublimelinter": true, "sublimelinter_executable_map": { "php":"/xampp/php/php.exe" } }

查看更多
Melony?
3楼-- · 2019-04-18 03:32

For windows I did this and it worked, use \\ and it should work!

{

  "sublimelinter_executable_map":
    {

        "php":"C:\\Users\\Wasil\\Documents\\BitNami\\php\\php-win.exe"
    }

}
查看更多
forever°为你锁心
4楼-- · 2019-04-18 03:35

I just had the same issue. The cause for my problem was that all PHP files where opened with the HTML5 syntax. You can check the current syntax by pasting the following command in your SublimeText console:

sublime.active_window().active_view().settings().get('syntax')

To set php as a default for the current file type, you can go to: view > syntax > Open all current extensions as... > php

Hope this helps!

查看更多
狗以群分
5楼-- · 2019-04-18 03:37

on MAC OS X in sublimeText 2 once you have installed sublimelint package

cmd+shift+p to open command palette then enter or select Preferences:SublimeLint - User

This will open the setting file

Paste this exactly:

{
    "sublimelinter": true,
    "sublimelinter_executable_map":
 {
     "php":"/usr/bin/php"
 }
}

Save the file and restart sublime text 2. if you have an error such as it could not read the file, it's because you made a typo mistake. The setting file it must be a correctly formatted json.

if you have any problems do a which php in your terminal to be sure php is installed at /usr/bin/php and replace the path by what the which command gives you if it's different.

查看更多
啃猪蹄的小仙女
6楼-- · 2019-04-18 03:37

i sovle this problem by change setting (where are bold) ,then restart sublime and try this php code to see sublime linter error

<?php echo "hello linter"  ?>

//not put semicolon you see red dot on next line of php code

just change setting like below

"linters": {
        "php": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "phpcs": {
            "@disable": true,
            "args": [],
            "excludes": [],
            "standard": "PSR2"
        }
    },
    "mark_style": "solid underline",
    "no_column_highlights_line": false,
    "passive_warnings": true,
    "paths": {
        "linux": [],
        "osx": [],
        "windows": [
            "put your php path or path of php.exe D:/wamp/bin/php/php5.4.3/"
        ]
    },

this two must change

"php": {
            "@disable": false,


        "phpcs": {
            "@disable": true,
查看更多
祖国的老花朵
7楼-- · 2019-04-18 03:41

I had to use this in my user settings:

{
    "sublimelinter": true,
    "sublimelinter_executable_map":
    { "php": "C:\\Program Files (x86)\\PHP\\v5.3\\php.exe"
    }
}
查看更多
登录 后发表回答