Skip to content

webtimal/vite-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Vite manifest parser and asset renderer for PHP, with HMR support for development.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages