SublimeLinter: PHP linting not working

送分小仙女□ 提交于 2020-01-01 23:58:07

问题


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?


回答1:


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" } }




回答2:


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!




回答3:


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.




回答4:


I had to use this in my user settings:

{
    "sublimelinter": true,
    "sublimelinter_executable_map":
    { "php": "C:\\Program Files (x86)\\PHP\\v5.3\\php.exe"
    }
}



回答5:


For my Windows i had to go with this: php.exe file path on Windows 7 didn't do the trick for me, while php-win.exe did:

{
    "sublimelinter_executable_map":
    {
        "php":"C:/php/php-win.exe"
    }
}



回答6:


Sometimes setting the php at the sublimlinter_executable_map does not work (for me). For me it just worked to add the path to the php.exe to the Windows System Environment Path Variable.




回答7:


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,



回答8:


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"
    }

}


来源:https://stackoverflow.com/questions/11817164/sublimelinter-php-linting-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!