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

PHPSnippets

by gerardroche ST2/ST3

PHP snippets for Sublime Text.

Labels php, snippets

Details

Installs

  • Total 73K
  • Win 51K
  • OS X 9K
  • Linux 13K
Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 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
Windows 32 47 35 45 53 73 53 98 46 44 61 51 59 63 58 53 39 54 52 66 66 80 47 50 59 66 59 54 69 37 41 41 53 72 62 60 43 50 47 59 65 66 63 36 57 59
OS X 4 5 5 8 10 4 11 2 3 6 7 7 12 8 8 7 10 5 6 12 7 5 12 5 6 9 5 4 7 4 5 9 5 9 7 7 4 5 5 11 8 3 6 6 10 7
Linux 6 4 7 3 12 16 26 11 6 7 11 8 7 12 13 6 14 7 19 11 16 12 9 15 12 20 11 14 3 4 7 12 17 19 13 5 8 8 7 9 10 13 12 9 6 13

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

INSTALLATION

Package Control installation

The preferred method of installation is Package Control.

Manual installation

Close Sublime Text, then download or clone this repository to a directory named PHPSnippets 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/PHPSnippets
  • OSX: git clone https://github.com/gerardroche/sublime-php-snippets.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/PHPSnippets
  • Windows: git clone https://github.com/gerardroche/sublime-php-snippets.git %APPDATA%\Sublime/ Text/ 3/Packages/PHPSnippets

USAGE

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

Enable tab-completions.

Menu > Preferences > Settings

{
    "tab_completion": true
}
Trigger Description
<? PHP: Script start tag
<?= PHP: Script short echo tag
/** PHP: Start Docblock
?= PHP: Script short echo tag
_C PHP: COOKIE['…']
_E PHP: ENV['…']
_F PHP: FILES['…']
_G PHP: GET['…']
_P PHP: POST['…']
_R PHP: REQUEST['…']
_S PHP: SERVER['…']
_SS PHP: SESSION['…']
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
dst PHP: declare strict_types statement
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
met PHP: function definition
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

Create a file named php-snippets-phtml-settings.tmPreferences in your User packages directory (Menu > Preferences > Browse Packages...) with the following (modified to meet your needs):

<?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>=</string>
            </dict>





        </array>
    </dict>
</dict>
</plist>

LICENSE

Released under the BSD 3-Clause License.