Improving PHP Development Workflow Efficiency With Sublime Text 2

I’ve recently been turned on to Sublime Text 2, and I’m loving it.  Jeffrey Way has done an excellent job of detailing exactly how you can improve your workflow with it, here. However, that link has a lot of videos, and they take a while to watch, so I will give a minimal crash-course in using Sublime Text 2 to develop PHP.

Why Is It Awesome?

It’s a very light editor, it’s incredibly fast (seriously, I have never used a more responsive editor), and… yadda yadda. You’ve heard it all before with the alternatives. Here are the two real killer features of this editor that make it shine, in my opinion:

  1. “Goto anything.” By pressing Ctrl+P (Mac: ⌘+P), you get a quick search box that allows you to look for anything — settings, files in the current project, etc. It does this via ultra-quick “fuzzy search,” and I can’t tell you how useful I find this. Now instead of having to go to the file pane, clicking to open /includes, then /modules, then foo.php, I can just Ctrl+P, type foo (maybe even just “fo”), and press enter. Think of how many files you open every day, and how much focus you waste trying to remember where they are; focus that could better be spent on your code.
  2. Snippets. Basically, if you type “if”, an option will pop up to create an if {} block for you. Other IDEs have this sort of thing, but Sublime does it one better. After you have it enter a snippet, it automatically puts your cursor where the first parameter/entrypoint/whatever is, and then if you press Tab it will go to the next. This is best shown in this video. Once you get accustomed to using snippets (and even creating your own), this will save you so much time.

It also has lots of extensions, which you can take a look into as well. Sublime Package Control is absolutely a must-have — with it, you can look up and install other extensions in about 2 seconds time (that is not an exaggeration). I also suggest SublimeCodeIntel which allows for better autocomplete (e.g. your own project’s functions can be autocompleted), as well as some other things, but the expanded autocomplete is what I use it for. I also use Sublime Tortoise, a TortoiseSVN plugin for Sublime, but due to one of the below peeves, it actually isn’t that useful.

What’s It Missing?

Let’s not kid ourselves: Sublime Text 2 is not a full IDE. It can’t (reliably) got to the definition of a function defined in a different file than you are currently looking at, and it doesn’t show function parameter hints. You can’t do step debugging. And so forth. If you want an IDE that does all of that, I suggest NetBeans (also cross-platform compatible).

One big pet peeve of mine is that when editing a file, the folder view on the left doesn’t highlight the file you’re editing. This is mainly annoying because when I want to perform a commit (via Sublime Tortoise), that means I have to go through the trouble of finding the file in the left pane, right-clicking, and committing. This seriously interrupts my workflow, to the point where I generally just keep a file browser window open and use TortoiseSVN for anything SVN-related.

How To Set It Up

  1. Download it and install it.
  2. Go to Sublime Package Control and follow the (very brief, very easy) instructions there. Bonus: nothing to download, just copy and paste some text! Honestly, I’m not sure why they don’t just include Package Control by default in Sublime.
  3. Install whatever other plugins you want through Package Control. I pointed out a few I like above. I suggest only installing one or two to begin with, then play around with Sublime a little before delving into more.

Other Resources

Here are a few links that can help you dig deeper into Sublime.

  • Perfect Workflow in Sublime Text 2 — Linked in the top of this post. Lots of videos showing you exactly how to do various things with Sublime, by Jeffrey Way. Of particular note is the snippets tutorial.  I definitely recommend checking out these tutorials when you’ve got the time to do so; they also include lots of little tips for Sublime to help you save a second here or there. And that’s what workflow optimization is all about.
  • Setting Up Sublime Text 2 for PHP Development — Stuart Herbert’s take on how to set up Sublime for good PHP development workflow.

Category(s): Tools
Tags: , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *