webtimal / vite-php
Integrates Vite assets into PHP apps, supporting development HMR and production builds.
v1.0.0
2026-03-20 19:47 UTC
Requires
- php: >=8.2
README
About
vite-php is a lightweight library for integrating Vite built assets with any PHP application.
By parsing Vite’s manifest.json, it resolves asset URLs and generates the required <script> and <link> tags.
HMR is supported through automatic hot file detection, enabling a seamless development workflow.
Installation
composer require webtimal/vite-php
Usage
1. Initialize a new Vite instance
<?php use Webtimal\Vite\Vite; $vite = new Vite( // Path to the manifest.json file manifest: __DIR__ .'/dist/manifest.json', // Public base path or URL base: '/dist', // Optional path to the hot file, containting the dev server URL hotfile: __DIR__ .'./hot' );
2. Use it to render the HTML tags
<!DOCTYPE html> <html lang="en"> <head> <?php $vite(['css/style.css', 'js/script.js']); ?> ...
License
This library is open-sourced software licensed under the MIT License.