xgqfrms / vscode

:cn: :rocket: Visual Studio Code & VSCode Code Snippets All in One 🎉
https://vscode.xgqfrms.xyz
MIT License
3 stars 1 forks source link

PHP & code snippets #64

Open xgqfrms opened 1 year ago

xgqfrms commented 1 year ago

PHP & code snippets

https://github.com/xgqfrms/vscode/blob/master/code-snippets/php.json

xgqfrms commented 1 year ago

vscode code snippets

https://code.visualstudio.com/docs/editor/userdefinedsnippets

.vscode/.code-snippets/

https://code.visualstudio.com/api/language-extensions/snippet-guide

{
  "contributes": {
    "snippets": [
      {
        "language": "javascript",
        "path": "./snippets.json"
      }
    ]
  }
}

https://www.freecodecamp.org/news/definitive-guide-to-snippets-visual-studio-code/

https://blog.csdn.net/chuohe6087/article/details/100681268

xgqfrms commented 1 year ago

https://stackoverflow.com/questions/44321000/visual-studio-code-user-snippets-not-working

{
  "PHP 8 Template": {
    "scope": "php, html",
    "prefix": "p8t",
    "body": [
      "<?php",
      "",
      "/**",
      " * ",
      " * @author xgqfrms",
      " * @license MIT",
      " * @copyright xgqfrms",
      " * @created 2022-12-1$1",
      " * @modified ",
      " * ",
      " * @description $2",
      " * @link http://www.webhacker.com/$3.php",
      " * ",
      " */",
      "",
      "$args = $_GET[\"args\"];",
      "// $params = $_POST[\"params\"];",
      "// $all_in_one = $_REQUEST[\"args\"];",
      "echo \"<h1 style=\"color: red;\">red color: $args</h1>\";",
      "/*",
      "",
      "",
      "*/",
      "",
      "?>"
    ],
    "description": "PHP 8 Template & code snippets!"
  }
}
xgqfrms commented 1 year ago

bug

vscode php code snippets not work

https://github.com/microsoft/vscode/issues/113476

https://github.com/microsoft/vscode/issues/75955

solution

image

image

https://stackoverflow.com/questions/44321000/visual-studio-code-user-snippets-not-working

xgqfrms commented 1 year ago

global code snippets

~/Library/Application Support/Code/User/snippets/php.code-snippets

.code-snippets

image

{
    // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
    // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
    // is left empty or omitted, the snippet gets applied to all languages. 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": {
    //  "scope": "javascript,typescript",
    //  "prefix": "log",
    //  "body": [
    //      "console.log('$1');",
    //      "$2"
    //  ],
    //  "description": "Log output to console"
    // }
}
{
  "PHP 8 Template": {
    "prefix": "p8t",
    "body": [
      "<?php",
      "",
      "/**",
      " * ",
      " * @author xgqfrms",
      " * @license MIT",
      " * @copyright xgqfrms",
      " * @created 2022-12-1$1",
      " * @modified ",
      " * ",
      " * @description $2",
      " * @link http://www.webhacker.com/$3.php",
      " * ",
      " */",
      "",
      "$args = $_GET[\"args\"];",
      "// $params = $_POST[\"params\"];",
      "// $all_in_one = $_REQUEST[\"args\"];",
      "echo \"<h1 style=\"color: red;\">red color: $args</h1>\";",
      "/*",
      "",
      "",
      "*/",
      "",
      "?>"
    ],
    "description": "PHP 8 Template & code snippets!"
  }
}

image

image

image