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 13K
  • Win 8K
  • OS X 2K
  • Linux 3K
Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6
Windows 3 17 20 13 15 23 32 19 20 6 15 8 14 18 22 16 13 9 10 17 10 8 5 15 8 9 13 9 14 17 15 5 16 19 16 6 12 11 13 10 16 14 22 15 7 19
OS X 1 6 7 1 2 5 8 7 5 2 0 5 1 3 9 7 3 0 1 4 1 5 1 1 1 2 3 6 1 6 5 1 1 1 3 3 6 5 2 2 3 4 3 1 1 1
Linux 0 9 4 1 4 9 9 5 6 3 2 6 5 8 3 6 1 3 4 5 3 2 5 3 2 3 4 6 5 4 4 3 2 8 2 4 2 5 1 3 5 2 4 2 3 2

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.