Skip to content
PHP

Essential Sublime Text 3 Plugins for PHP Developers

5 min read
Sublime Text 3 logo

Sublime Text has got to be one of the most popular text editors out there for coding. Although still in beta, Sublime Text 3 is a relatively stable and very usable. I’ve personally been using it for over 2 years now both at work and at home. It’s sophisticated, lightweight and easy to use. It also works on all the major platforms: Windows, OSX and Linux.

Sublime Text is not quite an IDE (Inte­grated Devel­op­ment Envi­ron­ment), but with the installation of a handful of packages/plugins you can really make it the ideal editor for developing PHP in.

There are some great packages out there for Sublime Text to help PHP developers improve quality of code and workflow. These are what I consider the essential packages for developing PHP in Sublime Text 3.

Package Control

First up is Package Control. Why this doesn’t come pre-installed I do not know. I suspect the majority of Sublime Text users will already have this installed, but if not get it now; it will make the installation of all the other packages listed here (and many more) extremely simple. It’s like the equivalent of apt-get or homebrew if you’re familiar with them. Rather than having to download manually or git clone packages to your Packages folder you can simply install (and remove) packages via the Command Palette.

Once you start using Package Control you will wonder how you survived without it!

SublimeLinter / SublimeLinter-php

Every developer makes the occasional typo; forgetting to close some brackets, missing off a semi-colon, etc.. To help avoid these mistakes we can use a linter. SublimeLinter provides a framework for linting. The linters themselves are distributed separately as additional packages; for PHP you will want SublimeLinter-php which provides an interface to php -l for checking syntax.

Other useful linters for developers include SublimeLinter-jshint for JavaScript, SublimeLinter-json for JSON and SublimeLinter-csslint for CSS.

phpcs

Well written code should use a consistent coding standard, i.e. type of indentation, naming conventions, use of whitespace, bracket placement, etc.. Whatever standard you are working to, phpcs will help you to conform to them.

Unlike the other packages this one requires a handful of external libraries and some configuration to get it working; you will need PHP CodeSniffer, PHP CodeSniffer Fixer, and PHP Mess Detector. Install these libraries and set their execution paths in the phpcs settings in Sublime and you should be good to go.

When you attempt to save a file it will sniff out any issues with the file’s styling. PHP Mess Detector will check for things like potential bugs, over-complicated expressions and redundant code.

You can define the coding standard you want to develop against in the package’s setting. Popular standards like PSR-2 and Zend are available, plus many custom ones like CakePHP that can be installed and configured.

EditorConfig

EditorConfig provides a way of maintaining some coding style consistency between different editors and IDEs. This is particularly valuable when collaborating with others, some of whom may not be using Sublime Text to code with. Styles for a project are defined in a .editorconfig file which can then be read by the text editor/IDE and enforce them. This is useful for defining tab styles and line endings among other things. Most editors have plugins available to support EditorConfig including Atom, Coda, PhpStorm and, of course, Sublime Text.

You can find out more about EditorConfig and what you can define in the .editorconfig file over on the official website. Details of the Sublime Text EditorConfig package can be found on GitHub.

DocBlockr

Good code should be well documented. PHPDoc is a pretty much universally accepted means of doing this in PHP; although many developers find documenting their code tedious. DocBlockr simplifies the process of adding PHPDoc (and JSDoc) comments by autocompleting /** by pressing Enter or tab taking away some of the pain.

Func­tion Name Dis­play

This is a really simple little package that displays the current function that the cursor is placed in the status bar at the bottom (next to the line number).

VCS Gutter

If you’re working with Git, Mercurial, or SVN then VCS Gutter is a handy package for adding visual clues as to what has changed in a file since the last commit. It will show a small icon in the gutter to indicate what has been added, modified or deleted.

One slight issue I’ve found with this package is that if you want to view a large log file in Sublime it can slow the responsiveness of the editor considerably. In these cases I tend to temporarily disable VCS Gutter using Package Control.

Final Words

Those are my seven essential packages for developing PHP in Sublime Text 3. What do you use? Feel free to contribute your suggestions in the comments below.

© 2024 Andy Carter