Skip to content

Instantly share code, notes, and snippets.

@teleclient
Forked from yidas/VS Code PHP Snippets
Created March 21, 2021 18:35
Show Gist options
  • Save teleclient/79da2bda6bc7c0d615941913ccd9413f to your computer and use it in GitHub Desktop.
Save teleclient/79da2bda6bc7c0d615941913ccd9413f to your computer and use it in GitHub Desktop.

Revisions

  1. @yidas yidas created this gist Dec 13, 2017.
    47 changes: 47 additions & 0 deletions VS Code PHP Snippets
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    {
    /*
    // Place your snippets for PHP here. Each snippet is defined under a snippet name and has a prefix, body and
    // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
    // same ids are connected.
    // Example:
    "Print to console": {
    "prefix": "log",
    "body": [
    "console.log('$1');",
    "$2"
    ],
    "description": "Log output to console"
    }

    */
    "print_r": {
    "prefix": "print_r",
    "body": [
    "print_r($1);"
    ],
    "description": "PHP print_r() function"
    },
    "try": {
    "prefix": "try catch",
    "body": [
    "try {",
    "\t$1",
    "} catch (\\Exception $$e) {",
    "\t",
    "}"
    ],
    "description": "Exceptions Block"
    },
    "try_catch_example": {
    "prefix": "try catch example",
    "body": [
    "try {",
    "\tthrow new Exception(\"${1:error message}\", ${2:400});",
    "} catch(\\Exception $$e) {",
    "\t${5:echo $$e->getCode(). $$e->getMessage();}",
    "}"
    ],
    "description": "Exceptions Block Example"
    },
    }