Laura
Laura

Reputation: 3373

SublimeLinter: PHP linting not working

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?

Upvotes: 22

Views: 16022

Answers (8)

Nicolas Manzini
Nicolas Manzini

Reputation: 8546

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.

Upvotes: 9

user3652881
user3652881

Reputation: 21

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,

Upvotes: 2

r00tandy
r00tandy

Reputation: 986

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.

Upvotes: 1

psantana
psantana

Reputation: 71

I had to use this in my user settings:

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

Upvotes: 4

user2325463
user2325463

Reputation: 1

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

}

Upvotes: 0

Mladen Janjetovic
Mladen Janjetovic

Reputation: 14634

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

Upvotes: 1

Joe Bergevin
Joe Bergevin

Reputation: 3268

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

Upvotes: 21

Johan
Johan

Reputation: 1988

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!

Upvotes: 8

Related Questions