Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3 Sublimelinter phplint and php not found?

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'
like image 979
Andy Avatar asked Dec 17 '13 13:12

Andy


3 Answers

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.

like image 80
jmk Avatar answered Nov 02 '22 08:11

jmk


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"
}
like image 35
Erwan Avatar answered Nov 02 '22 09:11

Erwan


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.

like image 5
Robert Went Avatar answered Nov 02 '22 07:11

Robert Went