A framework-agnostic PHP integration for resolving Vite development and production assets.
composer require php-forge/vite:^0.3The consuming application owns Vite and every JavaScript dependency. Production resolution needs Vite's build
manifest; see Installation for the vite.config.js settings and the resulting manifest path.
use PHPForge\Vite\Configuration\DevelopmentConfiguration;
use PHPForge\Vite\Html\HtmlRenderer;
use PHPForge\Vite\Vite;
$vite = Vite::create(
DevelopmentConfiguration::create(
devServerUrl: 'http://localhost:5173',
),
entrypoints: ['resources/js/app.js'],
);
echo HtmlRenderer::create()->render($vite->resolve());use PHPForge\Vite\Configuration\ProductionConfiguration;
use PHPForge\Vite\Html\HtmlRenderer;
use PHPForge\Vite\Vite;
$vite = Vite::create(
ProductionConfiguration::create(
manifestPath: '/srv/app/public/build/.vite/manifest.json',
assetBaseUrl: '/build',
),
entrypoints: ['resources/js/app.js'],
);
echo HtmlRenderer::create()->render($vite->resolve());Vite::resolve() emits AssetsResolved through an optional PSR-14 dispatcher. The asset resolution path never
imports a debug contract or calls a collector, so installing the package does not activate a debugger and a call
without a dispatcher emits no events. The collector and panel that do implement those contracts live apart, in
PHPForge\Vite\Debug, owned by this package.
See Debugger integration for the Yii2 and Yii3 wiring. It remains an unreleased prototype.
Yii2
Yii3