Skip to content

Repository files navigation

PHP Forge

Vite


PHPUnit Mutation Testing Easy Coding Standard Security

A framework-agnostic PHP integration for resolving Vite development and production assets.

Features

Feature overview

Installation

composer require php-forge/vite:^0.3

The 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.

Quick start

Development

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());

Production

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());

Debugger integration

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 Vite panel in Yii2
Yii3 Vite panel in Yii3

Documentation

Package information

PHP Latest Stable Version Total Downloads

Code quality

Codecov PHPStan Level Max Quality StyleCI

Social networks

Follow on X

License

License

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages