Lately I’ve been working quite a lot with unit test using SimpleTest - so I often had to run scripts directly from command line. But wouldn’t it be cool if I just could write a test and run it directly under my code editor without even leaving it? And if you using Sublime Text 2 (and I really recommend checking it out - it’s gorgeous, it’s slim, it’s ultra fast and you can do basically everything with it) - you easily can.

How to do it: from main menu choose: Tools -> Build System -> New Build System, new tab should pop up, now paste:

  "cmd": ["php", "$file"],
  "selector": "source.php"

Here’s quick explanation: it will run command php (I assume it’s available globally from your system) and pass full path for currently opened file as an argument. Selector on the other hand is useful when you have setup your build system as automatic - it will just choose your new build when you are working with php files.

Now save it in your User directory (I recommend creating subdirectory called build) as php.sublime-build. Open some php file that can be run from command line, hit CTRL+B (default shortcut) and enjoy ;).