PHP Snippets is a lightweight yet powerful extension that provides a collection of commonly used PHP code snippets, designed to speed up your workflow and boost your coding efficiency in Visual Studio Code.
- ⌨️ Insert PHP structures like functions, loops, conditionals, and classes instantly.
- 🔁 Ready-to-use code blocks:
foreach
,if
,try/catch
,PDO
, etc. - 🧩 Handy snippets for
echo
,json
,session_start
, and more. - 🛠 Clean, readable, and customizable snippet definitions.
Prefix | Description |
---|---|
echo |
Simple echo statement |
phpfn |
Function template |
if |
If condition |
foreach |
Foreach loop |
pdoselect |
PDO SELECT query |
include |
Include a PHP file |
require |
Require a file once |
class |
PHP class with constructor & method |
try |
Try-catch block |
jsonres |
JSON API response |
redirect |
Redirect using header |
now |
DateTime with formatted output |
session |
Start a session |
ternary |
Ternary operator |
for |
For loop |
define |
Define a constant |
This extension has no dependencies. Just install it and start using in .php
files.
This extension currently does not add any settings.
No known issues.
Please report bugs or ideas for improvements via GitHub Issues.
- ✅ Added over 15 ready-to-use PHP snippets.
Want to improve this extension or add your own snippets?
- Fork the repo
- Add or update snippets
- Create a pull request 🚀
Enjoy faster and smarter PHP coding with PHP Snippets for VS Code.
Happy coding! 🐘💻