Last active
August 26, 2022 20:17
-
-
Save daveromsey/c856de71b557a05c7e0dd5b280099e09 to your computer and use it in GitHub Desktop.
VS Code PHP User Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// 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" | |
// } | |
"Log var_export()": { | |
"prefix": "logv", | |
"body": ["error_log( '$1 ' . var_export( $2, true ) );"], | |
"description": "Do a var_export( $variable ) to PHP error log." | |
}, | |
"Exit with var_dump()": { | |
"prefix": "xvd", | |
"body": ["exit( var_dump( $0 ) );"], | |
"description": "Exit with var_dump()" | |
}, | |
"Exit with print_r()": { | |
"prefix": "xpr", | |
"body": ["exit( print_r( $0 ) );"], | |
"description": "Exit with print_r()" | |
}, | |
"Log print_r()": { | |
"prefix": "logp", | |
"body": ["error_log( print_r( $0, true ) );"], | |
"description": "Do a print_r( $variable ) to PHP error log." | |
}, | |
"Detailed Error Log": { | |
"prefix": "logd", | |
"body": [ | |
"error_log( print_r( (object)", | |
"\t[", | |
"\t\t'line' => __LINE__,", | |
"\t\t'file' => __FILE__,", | |
"\t\t'dump' => [", | |
"\t\t\t$0,", | |
"\t\t],", | |
"\t], true ) );" | |
], | |
"description": "Detailed error logging" | |
}, | |
"Log gettype()": { | |
"prefix": "logt", | |
"body": ["error_log( gettype( $0 ) );"], | |
"description": "Do a gettype( $variable ) to PHP error log." | |
}, | |
"Debug Filters": { | |
"prefix": "logf", | |
"body": ["add_action( 'all', function() { error_log( var_export( current_filter(), true ) ); } );"], | |
"description": "Logs current filter." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment