Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A JSON configuration file for Sublime Text 2 that provides a build system for PHP.

PHP Sublime Build System

About

This is a JSON configuration file for Sublime Text 2 that provides a build system for PHP.

  • Ctrl + B will run a lint check on the PHP syntax of a provided script.
  • Ctrl + Shift + B will execute the script under PHP's command line environment.
  • Several other commands are available via the Command Palette. (Ctrl + Shift + P)

Prerequisites

This requires Sublime Text 2 and may work (untested) in Sublime Text 3: http://www.sublimetext.com/

Currently, it is assumed that the PHP binary is installed and part of your operating system's PATH variable. If it isn't, you can substitute "php" in the "cmd" value with the full path to your PHP binary.

Installation

  • Windows: Place the .sublime-build file in %APPDATA%\Sublime Text 2\Packages\User\
  • Linux: Place the .sublime-build file in ~/.config/sublime-text-2/Packages/User/
  • Mac OS X: Place the .sublime-build file in ~/Library/Application Support/Sublime Text 2/Packages/User/
{
"selector": "source.php",
"cmd": ["php", "-l", "$file"],
"variants": [
{
"name": "Run",
"cmd": ["php", "$file"]
},
{
"name": "PHP Version",
"cmd": ["php", "-v"]
},
{
"name": "PHP Config",
"cmd": ["php", "--ini"]
},
{
"name": "PHP Info",
"cmd": ["php", "-i"]
},
{
"name": "PHP Modules",
"cmd": ["php", "-m"]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment