34

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

So I now have the following packages installed:

  • SublimeLinter
  • SublimeLinter-php
  • SublimeLinter-phplint

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

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

The console reads:

SublimeLinter: cannot locate 'phplint' 

SublimeLinter: cannot locate 'php'
Andrea
  • 11,801
  • 17
  • 65
  • 72
Andy
  • 631
  • 1
  • 6
  • 13
  • This is not about programming – 웃웃웃웃웃 Dec 17 '13 at 13:09
  • 8
    This is, however, very much about [a software tool commonly used by programmers](http://stackoverflow.com/help/on-topic), which is on-topic. I feel this question is specific, objective (non-subjective), answerable _on this site_, and useful. – Andrew Cheong Dec 17 '13 at 13:39
  • 2
    -1 is a bit harsh for a question in scope of the website? Thanks you for your input @acheong87 – Andy Dec 17 '13 at 14:35
  • 5
    Perfectly good question and I'm sure it will help many people. I was struggling with this for ages and was missing the sublimelinter-php package noted above – Robert Went Dec 19 '13 at 00:27

6 Answers6

57

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

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.

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.

jmk
  • 1,778
  • 15
  • 18
  • ST 3 showed a parsing error (Error trying to parse settings: Expected value in...) with the above copy/pasted into my user settings. I removed the empty linux and osx values and it saved without errors. Thanks for the tip. – wolfstevent Mar 07 '14 at 01:00
  • +1 Under windows, even with the php.exe path configured in the windows PATH variable I needed to put it too in the linter configuration. – cvsguimaraes Mar 12 '14 at 12:56
  • @wolfstevent: I just looked at my settings file again. There are indeed a couple of brackets that I seem to have either forgotten or that got added later. I edited my original answer. It should work now. – jmk Mar 14 '14 at 15:22
  • still say "no lint error" ..no linting even settings are fixed – xkeshav Apr 27 '16 at 09:35
  • This helped, even with using OSX! Thanks! – Azirius May 21 '16 at 18:58
13

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

WARNING: php deactivated, cannot locate '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 PATH environment variable), so that the executable’s directory is available to 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:

"sublimelinter_executable_map":
{
    "php": "C:\\xampplite\\php\\php.exe"
}
Erwan
  • 141
  • 1
  • 3
  • 1
    I just want to emphasize the fact about double backslashes in the path of Windows, therefore C:\\, not C://. That was the reason I struggled. Thanks Erwan – TeeJay Mar 01 '15 at 03:25
5

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

Open up the zip and copy phplint.exe and phpl.bat to your php directory (mine is 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.

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

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

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.

Robert Went
  • 2,944
  • 2
  • 17
  • 18
  • 1
    I can't find any phplint.exe in the archives I've downloaded nor in the cvs repository, are you sure about that ? – snoob dogg Oct 15 '18 at 22:49
2

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": [] } },

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

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

Moh .S
  • 1,920
  • 19
  • 19
1

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

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

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

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

Andy
  • 631
  • 1
  • 6
  • 13
0

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.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • Thanks @MattDMo, I have looked through the documentation and while a lot of it seems very thorough I could not find any information about actually hooking up the linter. – Andy Dec 23 '13 at 12:58