Sublime Text 3 Sublimelinter phplint and php not found?

36.9k views Asked by At

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'
6

There are 6 answers

5
jmk On BEST ANSWER

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.

1
MattDMo On

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.

1
Robert Went On

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.

0
Andy On

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/

1
Erwan On

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"
}
0
Moh .S On

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.