PHP code example of ngekoding / php-vite

1. Go to this page and download the library: Download ngekoding/php-vite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ngekoding / php-vite example snippets


use Ngekoding\Vite\Manifest;

$vite = new Manifest(
    false,                      // dev mode (true = development, false = production)
    '/path/to/manifest.json',   // path to manifest.json
    '/dist/'                    // public base path
);

$tags = $vite->createTags("index.ts");

$tags = $vite->createTags("index.ts", "consent-banner.ts");

$manifest->preloadImages();
$manifest->preloadFonts();

$manifest->preload(
    "json",              // file extension (without dot)
    "application/json",  // MIME type
    "fetch"              // preload `as` attribute
);

$url = $manifest->getURL("consent-banner.ts");