β‘ PHPX Tag Support (VS Code Extension)
PHPX Tag Support turns VS Code into a first-class IDE for
*.php
templates that mix
PHPX components, PPHP helpers and Prisma ORM calls.
Below you'll find everything you need to install, configure and get the most out of it β
written in the same TailwindCSS + DaisyUI style as the rest of your docs.
π Key Features at a Glance
π·οΈ Smart Component Handling
- Auto-import with Ctrl+. Β βΒ groups by namespace
- Tag / attribute / value completions with π enum-aware validation
- Hover cards show full FQCN + default props
π Code Generation
- Snippet
phpxclass
scaffolds a ready-to-go component - Automatic namespace detection & attribute helpers
π― IntelliSense Everywhere
- Function & variable completion inside
{{ }}
- JS string methods, template literals, store helpers
- Signature-help for
pphp.*
& Prisma calls
π‘οΈ Diagnostics & Fix-its
- Invalid enum values underlined in red β before you save
- Missing imports flagged with 1-click quick fix
- XML/HTML tag-pair & heredoc validation
βοΈ Installation
# Marketplace
β Open Extensions β’ search "PHPX Tag Support" β’ Install
# VSIX (offline)
β code --install-extension phpx-tag-support-0.0.1.vsix
π Five-Second Demo
- Type
<Button
in a PHPX view β tooltip complains "Missing import". - Press Ctrl+. β choose Add import.
- The extension inserts
use App\Components\{Button};
- Inside the tag, hit Space β see prop suggestions with types & defaults.
- Select
variant
; allowed values (`primary\|ghost`) show up inside quotes β Ctrl+Space cycles them.
πΊοΈ Intelligent Route Management
PHPX Tag Support now includes smart routing features that understand your application's route structure, providing auto-completion, validation, and navigation for anchor tags. Perfect for building navigation menus and internal links with confidence.
π― Route Auto-Completion
- Smart
href
completions in anchor tags - Shows all available routes from your app structure
- Filters as you type with fuzzy matching
π Route Navigation
- Ctrl+Click on href values jumps to route file
- Hover shows route file path and status
- Peek definition with F12
β‘ Auto-Discovery
- Automatically scans your
app/
directory - Updates routes when files change
- Manual refresh with Ctrl+Shift+P
π‘οΈ Route Validation
- Highlights invalid routes with red underlines
- Real-time validation as you type
- Suggests closest matching routes
π Route Features in Action
<!-- Type href=" and get instant completions -->
<a href="dashboard">Go to Dashboard</a> <!-- β
Valid route -->
<a href="profile/settings">Settings</a> <!-- β
Valid nested route -->
<a href="invalid-route">Broken</a> <!-- β Highlighted as invalid -->
<!-- Ctrl+Click any href value to jump to the route file -->
<nav class="menu">
<a href="">Home</a> <!-- β src/app/index.php -->
<a href="dashboard">Dashboard</a> <!-- β src/app/dashboard/index.php -->
</nav>
Pro Tip: The extension automatically converts file paths to clean route URLs:
src/app/index.php
β""
(home route)src/app/dashboard/index.php
β"dashboard"
src/app/blog/[slug]/index.php
β"blog/[slug]"
π‘ Usage Cheat-Sheet
What | How |
---|---|
Add missing import | Ctrl+. on tag β Select Add import |
Peek component source | F12 or Ctrl+Click tag name |
Generate new component | Type phpxclass β Tab |
Trigger value completion | Inside "β¦" press Ctrl+Space |
Navigate to route file | Ctrl+Click on href value |
Refresh routes | Ctrl+Shift+P β "Refresh Routes" |
Mustache Magic & Event Handlers
<div class="card p-4">
{{ user.name.padStart(10) }}
{{ `Hi ${user.name}!` }}
<Button onClick="handleSave" class="mt-2">
Save
</Button>
</div>
β’ Variables (user.name
) and JS methods (.padStart()
) auto-complete.
β’ Ctrl+Click on handleSave
jumps to the PHP function.
β’ Assignments inside {{ }}
raise a warning to keep templates side-effect-free.
π§ Recommended VS Code Settings
{
"editor.gotoLocation.single": "peek",
"editor.gotoLocation.multiple": "peek",
"phpx-tag-support.sourceRoot": "src"
}
π― Enumerated Props & the *
Wildcard
PHPX Tag Support reads @property
annotations to understand which strings are valid for a prop.
You have two flavours:
Annotation | Behaviour | Use When⦠|
---|---|---|
|
Strict list β only home, about, or contact are accepted. | You want to lock the prop to a finite set of values (e.g.Β variants, sizes). |
|
EnumΒ +Β wildcard β shows the three tokens first, but any other non-empty string is also valid. | You have common presets but still need flexibility (e.g.Β arbitrary slugs, colour names). |
π οΈ Live Behaviour
<!-- Wildcard version in action -->
<NavItems routes="about" /> <!-- β
OK -->
<NavItems routes="blog/42" /> <!-- β
OK (allowed by *) -->
<!-- Change annotation to strict list -->
<NavItems routes="blog/42" /> <!-- β Error: not in enum -->
**Rule of thumb:** add *
when you need freedom, remove it when you want the
linter to be uncompromising. IntelliSense still prioritises the listed tokens either way. π
π₯ Pro Tips
- Annotate props with enums (
dark|light|*
) to unlock value validation. - Use
settings/files-list.json
to keep routes up-to-date automatically. - Press Ctrl+Click on any href to jump straight to the route file.
- The extension works best with proper
class-log.json
and TypeScript definitions.
That's it! Your editor now knows your components, your props, and your routes β so you can focus on building, not boilerplate. Happy coding! β¨