DualLang PHP
Insert PHP boilerplate — functions, database connections and queries,
classes, error handling, JSON responses, canonical tags, config loading,
and IIS rewrite rules — with independently configurable languages
for docblock comments and for placeholder names.
Why
Many teams write docblocks in English (for wider readability / tooling)
but name functions and variables in their own language. This extension
doesn't assume either — you choose both, independently, from your
settings. It defaults to English for both, but either one can be
switched to Spanish independently, or mixed both ways.
Commands
Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run. Most
commands are written for PHP files; Insert IIS Rewrite Rule works in
any file since it targets web.config, not PHP.
| Command |
What it inserts |
DualLang PHP: Insert Function |
A function skeleton with a docblock (@param, @return) — use this as your starting point for any new function |
DualLang PHP: Insert DB Connection |
A mysqli connection block with connect_error handling — run this once per script/include before querying |
DualLang PHP: Insert Prepared Statement |
A mysqli prepared statement (prepare / bind_param / execute / get_result) — use after a connection already exists |
DualLang PHP: Insert Class |
A class skeleton with one typed property and a constructor — a starting point, add more properties/methods as needed |
DualLang PHP: Insert Try/Catch |
A try/catch block with error_log() — wrap any operation that can throw (DB calls, file I/O, external requests) |
DualLang PHP: Insert JSON Response |
A JSON API response pattern (Content-Type header + json_encode()) — use as the last step of an API endpoint |
DualLang PHP: Insert Canonical Tag |
An HTML <link rel="canonical"> tag — add to the <head> of every page for SEO |
DualLang PHP: Insert Config Variable |
A pattern for loading a secret/token from a separate, git-ignored file — use instead of hardcoding credentials |
DualLang PHP: Insert IIS Rewrite Rule |
A <rule> block for web.config — use inside <system.webServer><rewrite><rules> for clean-URL routing |
Each command inserts an editable snippet — use Tab to jump between
placeholders, same as any other VS Code snippet.
Settings
| Setting |
Values |
Default |
Meaning |
duallangPhp.docblockLanguage |
en, es |
en |
Language of the docblock description text |
duallangPhp.namingLanguage |
en, es |
en |
Language of placeholder function/variable names |
Change these under Settings → Extensions → DualLang PHP, or directly
in settings.json. Example — switching naming to Spanish while keeping
docblocks in English:
{
"duallangPhp.docblockLanguage": "en",
"duallangPhp.namingLanguage": "es"
}
Suggested keybindings
Commands don't ship with a default keybinding (to avoid clashing with
your existing setup). To bind one yourself, open
Keyboard Shortcuts (Ctrl+K Ctrl+S) and search for DualLang PHP,
or add to keybindings.json:
{
"key": "ctrl+alt+f",
"command": "duallangPhp.insertFunction",
"when": "editorLangId == php"
}
Contributing / extending
Language text lives in a single STRINGS object in src/extension.ts.
Adding support for another language (e.g. French) means adding one new
entry there — no changes needed to the command logic itself.
License
MIT