Thursday, February 7, 2013

SublimeLinter not working for PHP files

Sublime Text 2 is a great code editor. I've been using it for over a year as my default editor after moving on from EditPlus2. It's fast and features a great file overview sidebar, file tabbing, project saving and a customisable colour interface.

After an unsuccessful attempt at installing SublimeLinter months ago, I decided to give it another go. SublimeLinter is a syntax checker package for SublimeText and allows for auto syntax checking.

You need the Package Control plugin first to automate the installation and upgrading of plugins. Follow the instructions on the Installing section of SublimeLinter page to install it.

From here, PHP linting did not work for me.
After searching online, 2 fixes on Stack Overflow worked for me:

1. Set the syntax type for PHP files to PHP instead of HTML5

2. Point SublimeLinter to your PHP exe:
  • Set your PC PATH environment variable e.g. C:\xampp\php, then update the SublimeLinter executable map by:
    • Preferences -> Package Settings -> SublimeLinter -> Settings-Default
    • In "sublimelinter_executable_map", enter "php":"php" between the { and }

After this, SublimeLinter highlights any PHP syntax errors automatically :-)

No comments:

Post a Comment