ViteHelper
extends Helper
in package
Helper for resolving Vite-built assets via the build manifest.
Reads .vite/manifest.json from webroot and generates properly
versioned <script> and <link> tags for production builds.
Table of Contents
Properties
- $Html : HtmlHelper
- $Url : UrlHelper
- $helpers : array<string|int, mixed>
- $manifest : array<string|int, mixed>|null
- Cached manifest data.
Methods
- css() : string|null
- Render a `<link>` tag for a Vite-built CSS asset.
- getScriptUrl() : string
- Get the versioned URL for a script asset (for service worker cache lists).
- getStyleUrl() : string
- Get the versioned URL for a CSS asset (for service worker cache lists).
- reset() : void
- Reset the cached manifest (useful for testing).
- script() : string|null
- Render a `<script>` tag for a Vite-built JS asset.
- getManifest() : array<string, array<string, mixed>>
- Load and cache the Vite manifest.
Properties
$Html
public
HtmlHelper
$Html
$Url
public
UrlHelper
$Url
$helpers
protected
array<string|int, mixed>
$helpers
= ['Html', 'Url']
$manifest
Cached manifest data.
private
static array<string|int, mixed>|null
$manifest
= null
Methods
css()
Render a `<link>` tag for a Vite-built CSS asset.
public
css(string $name[, array<string|int, mixed> $options = [] ]) : string|null
Parameters
- $name : string
-
Logical name (e.g., 'app', 'signin', 'dashboard')
- $options : array<string|int, mixed> = []
-
HtmlHelper::css options
Return values
string|nullgetScriptUrl()
Get the versioned URL for a script asset (for service worker cache lists).
public
getScriptUrl(string $name) : string
Parameters
- $name : string
-
Logical script name
Return values
string —Versioned URL path
getStyleUrl()
Get the versioned URL for a CSS asset (for service worker cache lists).
public
getStyleUrl(string $name) : string
Parameters
- $name : string
-
Logical CSS name
Return values
string —Versioned URL path
reset()
Reset the cached manifest (useful for testing).
public
static reset() : void
script()
Render a `<script>` tag for a Vite-built JS asset.
public
script(string $name[, array<string|int, mixed> $options = [] ]) : string|null
Parameters
- $name : string
-
Logical name (e.g., 'index', 'controllers')
- $options : array<string|int, mixed> = []
-
HtmlHelper::script options
Return values
string|nullgetManifest()
Load and cache the Vite manifest.
private
getManifest() : array<string, array<string, mixed>>