//ruta a la carpeta de los snipets en el archivo: //~/.config/Code/User/profiles/ //-54d2ca4b/snippets/ //Configure User Snippets este es el comando el de abajo es atajos rapidos de teclado //y con Con Ctrl + Shift + P se abre la paleta de comandos, donde puedes escribir "Open Keyboard Shortcuts (JSON)" // --- INICIO SNIPPETS PHP --- { // --- SNIPPETS PHP --- "Hola Mundo PHP": { "prefix": "phphola", "body": [ "// Imprime Hola Mundo en PHP", "echo \"Hola, ${1:mundo}!\";" ], "description": "Imprime un saludo básico en PHP", "scope": "php" }, "Echo Variable": { "prefix": "echo", "body": [ "// Imprime una variable", "echo ${1:variable};" ], "description": "Imprime una variable con echo", "scope": "php" }, "If Statement": { "prefix": "if", "body": [ "// Estructura if con sintaxis alternativa", "if (${1:condition}):", "\t$0", "endif;" ], "description": "Estructura if con sintaxis alternativa", "scope": "php" }, "If-Else Statement": { "prefix": "ifelse", "body": [ "// Estructura if-else con sintaxis alternativa", "if (${1:condition}):", "\t${2:código si verdadero}", "else:", "\t${3:código si falso}", "endif;" ], "description": "Estructura if-else con sintaxis alternativa", "scope": "php" }, "Foreach Loop": { "prefix": "foreach", "body": [ "// Bucle foreach con sintaxis alternativa", "foreach (${1:array} as ${2:key} => ${3:value}):", "\t$0", "endforeach;" ], "description": "Bucle foreach con sintaxis alternativa", "scope": "php" }, "For Loop": { "prefix": "for", "body": [ "// Bucle for con sintaxis alternativa", "for (${1:i} = 0; ${1:i} < ${2:count(array)}; ${1:i}++):", "\t$0", "endfor;" ], "description": "Bucle for con sintaxis alternativa", "scope": "php" }, "Function Declaration": { "prefix": "function", "body": [ "// Declarar función en PHP", "function ${1:nombreFuncion}(${2:parametros}) {", "\t$0", "}" ], "description": "Declarar una función en PHP", "scope": "php" }, "Class Constructor": { "prefix": "classconstructor", "body": [ "// Crear clase con constructor", "class ${1:NombreClase} {", "\tpublic function __construct(${2:parametros}) {", "\t\t$0", "\t}", "}" ], "description": "Clase PHP con constructor", "scope": "php" }, "Class con Propiedades y Métodos": { "prefix": "classfull", "body": [ "// Clase con propiedad, constructor, getter y setter", "class ${1:NombreClase} {", "\t/**", "\t * @var ${2:string} Descripción de la propiedad", "\t */", "\tprivate \${3:nombre};", "", "\t/**", "\t * Constructor", "\t *", "\t * @param ${2:string} \${3:nombre} Descripción", "\t * @throws InvalidArgumentException", "\t */", "\tpublic function __construct(${2:string} \${3:nombre} = '') {", "\t\t$this->set${4/(.+)/${1:/capitalize}/}(\${3:nombre});", "\t}", "", "\t/**", "\t * Setter para ${3:nombre}", "\t *", "\t * @param ${2:string} \${3:nombre}", "\t * @return void", "\t * @throws InvalidArgumentException", "\t */", "\tpublic function set${4/(.+)/${1:/capitalize}/}(${2:string} \${3:nombre}): void {", "\t\tif (empty(\${3:nombre})) {", "\t\t\tthrow new InvalidArgumentException('El ${3:nombre} no puede estar vacío.');", "\t\t}", "\t\t$this->${3:nombre} = \${3:nombre};", "\t}", "", "\t/**", "\t * Getter para ${3:nombre}", "\t *", "\t * @return ${2:string}", "\t */", "\tpublic function get${4/(.+)/${1:/capitalize}/}(): ${2:string} {", "\t\treturn \$this->${3:nombre};", "\t}", "}" ], "description": "Clase con propiedades, constructor, getter y setter con validación", "scope": "php" }, "Try Catch": { "prefix": "trycatch", "body": [ "// Bloque try-catch", "try {", "\t$0", "} catch (${1:Exception} ${2:e}) {", "\techo ${2}->getMessage();", "}" ], "description": "Bloque try-catch en PHP", "scope": "php" }, "Variable Dump": { "prefix": "vardump", "body": [ "// Mostrar variable legible", "echo '<pre>';", "var_dump(${1:variable});", "echo '</pre>';" ], "description": "Mostrar variable con var_dump formateado", "scope": "php" }, "PHP Array": { "prefix": "array", "body": [ "// Crear array asociativo", "${1:arrayName} = [", "\t${2:'key' => 'value'},", "\t$0", "];" ], "description": "Crear array asociativo en PHP", "scope": "php" }, // --- SNIPPETS POSTGRES --- "Postgres Select": { "prefix": "pgSelect", "body": [ "-- Consulta SELECT básica", "SELECT ${1:*} FROM ${2:tabla} WHERE ${3:condicion};" ], "description": "Consulta SELECT en Postgres", "scope": "sql" }, "Postgres Insert": { "prefix": "pgInsert", "body": [ "-- Consulta INSERT básica", "INSERT INTO ${1:tabla} (${2:columna1}, ${3:columna2}) VALUES (${4:valor1}, ${5:valor2});" ], "description": "Consulta INSERT en Postgres", "scope": "sql" }, "Postgres Update": { "prefix": "pgUpdate", "body": [ "-- Consulta UPDATE básica", "UPDATE ${1:tabla} SET ${2:columna} = ${3:nuevo_valor} WHERE ${4:condicion};" ], "description": "Consulta UPDATE en Postgres", "scope": "sql" }, "Postgres Delete": { "prefix": "pgDelete", "body": [ "-- Consulta DELETE básica", "DELETE FROM ${1:tabla} WHERE ${2:condicion};" ], "description": "Consulta DELETE en Postgres", "scope": "sql" }, "Postgres Create Table": { "prefix": "pgCreateTable", "body": [ "-- Crear tabla", "CREATE TABLE ${1:tabla} (", "\t${2:id} SERIAL PRIMARY KEY,", "\t${3:columna} ${4:tipo},", "\t$0", ");" ], "description": "Crear tabla en Postgres", "scope": "sql" }, "Postgres Connect": { "prefix": "pgConnect", "body": [ "-- Conectar a base de datos Postgres", "\\c ${1:nombre_base_de_datos};" ], "description": "Conectar a base de datos Postgres", "scope": "sql" }, "Postgres Drop Database": { "prefix": "pgDropDb", "body": [ "-- Borrar base de datos", "DROP DATABASE ${1:nombre_base_de_datos};" ], "description": "Borrar base de datos en Postgres", "scope": "sql" }, "Postgres Create Database": { "prefix": "pgCreateDb", "body": [ "-- Crear base de datos", "CREATE DATABASE ${1:nombre_base_de_datos};" ], "description": "Crear base de datos en Postgres", "scope": "sql" }, "Postgres Import Database": { "prefix": "pgImportDb", "body": [ "-- Importar archivo .sql", "psql -U ${1:usuario} -d ${2:base_de_datos} -f ${3:archivo.sql}" ], "description": "Importar archivo .sql a Postgres", "scope": "sql" }, "Postgres Export Database": { "prefix": "pgExportDb", "body": [ "-- Exportar base de datos a archivo .sql", "pg_dump -U ${1:usuario} -d ${2:base_de_datos} -f ${3:archivo.sql}" ], "description": "Exportar base de datos Postgres", "scope": "sql" }, "Postgres Create User": { "prefix": "pgCreateUser", "body": [ "-- Crear usuario", "CREATE USER ${1:nombre_usuario} WITH PASSWORD '${2:contraseña}';" ], "description": "Crear usuario en Postgres", "scope": "sql" }, "Postgres Grant Privileges": { "prefix": "pgGrant", "body": [ "-- Otorgar privilegios", "GRANT ${1:ALL} PRIVILEGES ON DATABASE ${2:base_de_datos} TO ${3:usuario};" ], "description": "Otorgar privilegios en Postgres", "scope": "sql" }, // --- SNIPPETS LARAVEL --- "Laravel Route": { "prefix": "laravelRoute", "body": [ "// Definir ruta en Laravel", "Route::${1:get}('${2:/ruta}', [${3:Controller}::class, '${4:metodo}']);" ], "description": "Definir ruta en Laravel", "scope": "php" }, "Laravel Controller": { "prefix": "laravelController", "body": [ "// Controlador básico en Laravel", "namespace App\\Http\\Controllers;", "", "use Illuminate\\Http\\Request;", "", "class ${1:NombreController} extends Controller", "{", "\tpublic function ${2:index}()", "\t{", "\t\t$0", "\t}", "}" ], "description": "Controlador básico en Laravel", "scope": "php" }, "Laravel Migration": { "prefix": "laravelMigration", "body": [ "// Crear migración en Laravel", "Schema::create('${1:tabla}', function (Blueprint $table) {", "\t$table->id();", "\t$table->string('${2:nombre}');", "\t$table->timestamps();", "\t$0", "});" ], "description": "Migración básica en Laravel", "scope": "php" }, "Laravel Model": { "prefix": "laravelModel", "body": [ "// Crear modelo en Laravel", "namespace App\\Models;", "", "use Illuminate\\Database\\Eloquent\\Model;", "", "class ${1:NombreModelo} extends Model", "{", "\tprotected $fillable = [", "\t\t'${2:campo}',", "\t];", "\t$0", "}" ], "description": "Modelo básico en Laravel", "scope": "php" }, "Laravel Blade Foreach": { "prefix": "laravelForeach", "body": [ "{{-- Bucle foreach en Blade --}}", "@foreach (${1:items} as ${2:item})", "\t{{ ${2:item} }}", "@endforeach" ], "description": "Bucle foreach en Blade", "scope": "php" }, "Laravel Validation": { "prefix": "laravelValidate", "body": [ "// Validar datos en controlador", "$validated = $request->validate([", "\t'${1:campo}' => '${2:required|string}',", "\t$0", "]);" ], "description": "Validación de datos en Laravel", "scope": "php" }, "Laravel Seeder": { "prefix": "laravelSeeder", "body": [ "// Crear seeder en Laravel", "use Illuminate\\Database\\Seeder;", "", "class ${1:NombreSeeder} extends Seeder", "{", "\tpublic function run()", "\t{", "\t\t$0", "\t}", "}" ], "description": "Seeder básico en Laravel", "scope": "php" }, "Laravel Request": { "prefix": "laravelRequest", "body": [ "// Obtener datos de petición", "\$${1:variable} = $request->input('${2:campo}');" ], "description": "Obtener datos de petición en Laravel", "scope": "php" }, "Laravel Middleware": { "prefix": "laravelMiddleware", "body": [ "// Crear middleware en Laravel", "namespace App\\Http\\Middleware;", "", "use Closure;", "", "class ${1:NombreMiddleware}", "{", "\tpublic function handle($request, Closure $next)", "\t{", "\t\t$0", "\t\treturn $next($request);", "\t}", "}" ], "description": "Middleware básico en Laravel", "scope": "php" }, "Laravel Blade If": { "prefix": "laravelBladeIf", "body": [ "{{-- Estructura if en Blade --}}", "@if (${1:condicion})", "\t${2:contenido}", "@endif" ], "description": "Estructura if en Blade", "scope": "php" }, "Laravel Blade Include": { "prefix": "laravelBladeInclude", "body": [ "{{-- Incluir vista en Blade --}}", "@include('${1:vista}')" ], "description": "Incluir vista en Blade", "scope": "php" }, "Laravel Blade Layout": { "prefix": "laravelBladeLayout", "body": [ "{{-- Extender layout en Blade --}}", "@extends('${1:layouts.app}')", "", "@section('${2:content}')", "\t$0", "@endsection" ], "description": "Extender layout en Blade", "scope": "php" } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter