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

php-snippets

by gerardroche ST2/ST3

PHP snippets for Sublime Text

Labels php, snippets

Details

Installs

  • Total 45K
  • Win 30K
  • OS X 6K
  • Linux 8K
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 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9
Windows 33 51 34 49 55 47 40 53 47 27 34 53 46 35 53 54 46 39 62 57 49 47 53 30 41 49 39 45 49 54 40 45 62 54 71 64 75 49 46 53 87 57 43 35 51 29
OS X 4 12 3 6 9 8 3 13 8 8 7 3 7 1 13 6 7 8 6 6 12 7 11 8 9 15 11 12 13 6 4 2 9 8 12 12 11 7 7 11 12 11 6 3 5 4
Linux 2 12 7 6 14 11 13 16 16 5 14 8 11 4 9 13 6 7 16 9 12 18 12 8 7 14 11 17 10 15 9 3 14 10 9 13 9 9 12 11 30 13 5 6 4 8

Readme

Source
raw.​githubusercontent.​com

WHAT PHP SNIPPETS IS

PHP snippets for Sublime Text.

Minimum Sublime Version Latest Stable Version GitHub stars Downloads Author

  • PSR compliant
  • Scoped to minimise auto-complete noise

Overview

INSTALLATION

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-snippets in the Sublime Text Packages directory for your platform:
    • Linux: git clone https://github.com/gerardroche/sublime-php-snippets.git ~/.config/sublime-text-3/Packages/php-snippets
    • OS X: git clone https://github.com/gerardroche/sublime-php-snippets.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/php-snippets
    • Windows: git clone https://github.com/gerardroche/sublime-php-snippets.git %APPDATA%\Sublime/ Text/ 3/Packages/php-snippets
  3. Done!

USAGE

OS X Windows Linux Description
Command+Space Ctrl+Space Alt+/ Activate completions

Enable tab-completions.

Preferences > Settings

{
    "tab_completion": true
}
Trigger Description
$_ PHP: COOKIE['…']
$_ PHP: ENV['…']
$_ PHP: FILES['…']
$_ PHP: GET['…']
$_ PHP: POST['…']
$_ PHP: REQUEST['…']
$_ PHP: SERVER['…']
$_ PHP: SESSION['…']
<? PHP: Script start tag
<?= PHP: Script short echo tag
/** PHP: Start Docblock
?= PHP: Script short echo tag
am PHP: array map a closure
array PHP: Initialise a variable with an array
c PHP: class declaration
case PHP: case statement
class PHP: class declaration
closure PHP: Closure declaration
con PHP: class constructor definition
def PHP: define(…, …)
def? PHP: defined(…)
do PHP: do-while statement
doc_c PHP: Documented class
doc_d PHP: Documented constant definition
doc_f PHP: Documented function
doc_i PHP: Documented interface
doc_s PHP: Documented function signature
doc_v PHP: Documented class variable
echo PHP: echo '…'
echo PHTML: <?php echo … ?>
echoh PHTML: echo htmlentities(…)
else PHP: else statement
else PHTML: else statement
elseif PHP: elseif statement
elseif PHTML: elseif statement
endfor PHTML: endfor statement
endforeach PHTML: endforeach statement
endif PHTML: endif statement
endswitch PHTML: endswitch statement
endwhile PHTML: endwhile statement
ethis PHP: echo $this->
ethis PHTML: <?php echo $this->… ?>
ev PHP: echo '…'
f PHP: function definition
flatten PHP: Flatten an array
for PHP: for statement
foreach PHP: foreach {value} statement
foreach PHTML: foreach {value} statement
foreachk PHP: foreach {key} {value} statement
foreachk PHTML: foreach {key} {value} statement
fpri PHP: final private class method declaration
fpris PHP: final private static class method declaration
fpro PHP: final protected class method declaration
fpub PHP: final public class method declaration
fpubs PHP: final public static class method declaration
fun PHP: function definition
getter PHP: getter
globals PHP: $GLOBALS['…']
gm PHP: getter
i PHP: interface definition
if PHP: if statement
if PHTML: if statement
if? PHP: $… = ( … ) ? … : …
ifelse PHP: if-else statement
ifelse PHTML: if-else statement
inc PHP: include expression
inc1 PHP: include_once expression
is PHP: $… = ( … ) ? … : …
kv PHP: Array key value
m PHP: class method declaration
n PHP: namespace definition
namespace PHP: namespace definition
p PHP: class property declaration
php PHTML: <?php … ?>
pr PHP: Print human readable information about a variable
pre PHP: Print human readable information about a variable and exit
pri PHP: private class method declaration
pro PHP: protected class method declaration
pub PHP: public class method declaration
pubs PHP: public static class method declaration
r PHP: return statement
req PHP: require expression
req1 PHP: require_once expression
reqd PHP: require dirname expression
ret PHP: return
ret0 PHP: return false statement
ret1 PHP: return true statement
retf PHP: return false statement
rett PHP: return true statement
rt PHP: return $this statement
rv PHP: return variable statement
self PHP: self::
setter PHP: setter
sm PHP: setter
switch PHP: switch statement
t PHP: $this->
this PHP: $this->
this PHTML: <?php $this->… ?>
throw PHP: throw exception statement
trait PHP: trait definition
try PHP: Wrap in try { … } catch (…) { … }
use PHP: namespace use declaration
vd PHP: Dump information about a variable
vde PHP: Dump information about a variable and exit
while PHP: while statement

CONFIGURATION

Short echo tags vs long echo tags

By default echo in snippets expand to a short php tag.

<?= $var ?>

If you prefer long tags.

<?php echo $var ?>

Create a file **php-snippets-phtml-settings.tmPreferences** in your User packages directory (Menu > Preferences > Browse Packages...).

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>name</key>
    <string>php-snippets phtml settings</string>
    <key>scope</key>
    <string>text.html.basic</string>
    <key>settings</key>
    <dict>
        <key>shellVariables</key>
        <array>
            <dict>
                <key>name</key>
                <string>TM_PHP_OPEN_TAG_WITH_ECHO</string>
                <key>value</key>
                <string>php echo</string>
            </dict>
        </array>
    </dict>
</dict>
</plist>

CONTRIBUTING

Your issue reports and pull requests are always welcome.

LICENSE

Released under the BSD 3-Clause License.