webtimal/vite-php

Integrates Vite assets into PHP apps, supporting development HMR and production builds.

Maintainers

Package info

github.com/webtimal/vite-php

pkg:composer/webtimal/vite-php

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-20 19:47 UTC

This package is auto-updated.

Last update: 2026-04-23 16:57:09 UTC


README

Laravel Logo

PHP 8.2+

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.