Skip to content

Instantly share code, notes, and snippets.

@leotop
Forked from xcjs/PHP.sublime.build
Last active August 29, 2015 14:10
Show Gist options
  • Save leotop/47f056c1515d9c59648f to your computer and use it in GitHub Desktop.
Save leotop/47f056c1515d9c59648f to your computer and use it in GitHub Desktop.

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