ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

php-grammar

by gerardroche ST3

An improved PHP syntax for Sublime Text, indentation rules, smart completions, and more.

Details

Installs

  • Total 14K
  • Win 9K
  • OS X 2K
  • Linux 3K
Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9
Windows 13 10 15 23 19 14 13 17 9 15 14 10 15 20 16 13 15 22 19 19 23 20 8 16 13 12 14 9 14 11 17 13 10 18 19 19 11 15 8 10 5 9 16 16 19 15
OS X 1 2 4 3 2 0 1 4 8 3 3 2 3 3 4 6 5 7 9 7 6 5 6 1 0 1 0 3 3 3 3 5 1 0 4 4 2 2 7 7 1 4 1 2 6 1
Linux 5 6 6 5 2 4 5 3 4 6 4 3 5 7 4 6 4 4 3 3 6 10 4 0 3 4 5 2 3 8 2 8 0 3 7 5 9 5 5 3 3 4 3 3 3 4

Readme

Source
raw.​githubusercontent.​com

WHAT PHP GRAMMAR IS

An improved PHP syntax, good indentation rules, smart macros, and more.

Minimum Sublime Version Latest Stable Version GitHub stars Downloads Author

  • Supports PHP ~7
  • Improved support for syntax highlighters
  • Good indentation rules
  • Smart macros

Completions and snippets are provided separately by PHP Completions Kit and php-snippets.

OVERVIEW

INSTALLATION

For a PHP 5.6 specific version, manually install and checkout the 5.x branch.

Package Control installation

The preferred method of installation is Package Control.

Manual installation

  1. Close Sublime Text.
  2. Download or clone this repository to a directory named php-grammar in the Sublime Text Packages directory for your platform:
    • Linux: git clone https://github.com/gerardroche/sublime-php-grammar.git ~/.config/sublime-text-3/Packages/php-grammar
    • OS X: git clone https://github.com/gerardroche/sublime-php-grammar.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/php-grammar
    • Windows: git clone https://github.com/gerardroche/sublime-php-grammar.git %APPDATA%\Sublime/ Text/ 3/Packages/php-grammar
  3. Done!

Note that if you disable or remove this package, you will need to re-enable the native PHP package manually.

USAGE

Smart macros

To insert a character overridden by a smart macro: prefix with Ctrl or Shift.

Ctrl+Enter

array(                      | array(
    'str|'                  |     'str',
)                           |     |
                            | )
'str|ing'                   | 'string';
                            | |
function_call(|)            | function_call();
                            | |
if ($condition|)            | if ($condition) {
                            |     |
                            | }
foreach ($x => $y|)         | foreach ($x => $y) {
                            |     |
                            | }
while ($condition|)         | while ($condition) {
                            |     |
                            | }
for ($i = 0; $i < ; $i++|)  | for ($i = 0; $i < ; $i++) {
                            |     |
                            | }
switch ($condition|)        | switch ($condition|) {
                            |     |
                            | }
function x(|)               | function x()
                            | {
                            |     |
                            | }
class x                     | class x
{                           | {
    public function y(|)    |     public function y()
}                           |     {
                            |         |
                            |     }
                            | }

Ctrl+;

'str|ing'                   | 'string';|
function_call(|)            | function_call();|

Enter

array(|)                    | array(
                            |     |
                            | )
function_call(|)            | function_call(
                            |     |
                            | )
new class_name(|)           | new class_name(
                            |     |
                            | )

Tab

$arr = array(               | $arr = array(
    'str|'                  |     'str' => |
)                           | )
$arr = array(               | $arr = array(
    'str'|                  |     'str' => |
)                           | )

[

$arr = |                    | $arr = [|];

]

$arr = [|                   | $arr = [|];

Indentation rules

To reindent:

  1. select the code to reindent
  2. select Menu > Edit > Line > Reindent

Example

Original                   ->  Reindented

$val = array(                | $val = array(
array(                       |     array(
array(                       |         array(
array(                       |             array(
array(                       |                 array(
array(                       |                     array(
)                            |                     )
)                            |                 )
)                            |             )
)                            |         )
),                           |     ),
'x' => 'y',                  |     'x' => 'y',
"multi" => array(            |         "multi" => array(
"dimensional" => array(      |             "dimensional" => array(
"array" => "x"               |                 "array" => "x"
'x' => array(                |                 'x' => array(
'y' => 'z'                   |                     'y' => 'z'
)                            |                 )
)                            |             )
)                            |     )
);                           | );

CONTRIBUTING

See CONTRIBUTING.md.

CHANGELOG

See CHANGELOG.md.

CREDITS

Originally converted from the PHP TextMate package bundled with Sublime Text.

LICENSE

Released under the BSD 3-Clause License.