Skip to content

Instantly share code, notes, and snippets.

@xcjs
Created July 25, 2013 00:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xcjs/6075914 to your computer and use it in GitHub Desktop.
Save xcjs/6075914 to your computer and use it in GitHub Desktop.
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"]
}
]
}
@rahitashpaul
Copy link

what about this i found it:
{
"cmd": ["php.exe", "$file"], // php location
"file_regex": "php$",
"selector": "source.php",
"file_patterns": ["*.php"],
}

AND
what about I download php from php.net and sublime text.
how I can cofigure php build in sublime text without xamp or anyother

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment