Sublime Text 3 Sublimelinter phplint and php not found?
Asked Answered
C

6

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'
Cakewalk answered 17/12, 2013 at 13:8 Comment(4)
This is not about programmingMagnitogorsk
This is, however, very much about a software tool commonly used by programmers, which is on-topic. I feel this question is specific, objective (non-subjective), answerable on this site, and useful.Muzhik
-1 is a bit harsh for a question in scope of the website? Thanks you for your input @acheong87Cakewalk
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 aboveAlphonsa
P
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.

Planimetry answered 19/12, 2013 at 13:23 Comment(4)
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.Cheyennecheyne
+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.Factorize
@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.Planimetry
still say "no lint error" ..no linting even settings are fixedSpan
F
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"
}
Flooring answered 3/3, 2014 at 5:44 Comment(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 ErwanDraw
A
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.

Alphonsa answered 17/12, 2013 at 21:29 Comment(1)
I can't find any phplint.exe in the archives I've downloaded nor in the cvs repository, are you sure about that ?Lyonnaise
D
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.

Danndanna answered 14/8, 2017 at 6:17 Comment(0)
C
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/

Cakewalk answered 30/1, 2014 at 12:18 Comment(0)
W
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.

Wheelman answered 17/12, 2013 at 15:59 Comment(1)
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.Cakewalk

© 2022 - 2024 — McMap. All rights reserved.