PHP code example of idleberg / vite-manifest

1. Go to this page and download the library: Download idleberg/vite-manifest 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/ */

    

idleberg / vite-manifest example snippets


new Manifest(string $manifestPath, string $baseUri, string $algorithm = "sha256");

use Idleberg\ViteManifest\Manifest;

$baseUrl = "https://idleberg.github.io";
$manifest = "path/to/manifest.json";

$vm = new Manifest($manifest, $baseUrl);

$entrypoint = $vm->getEntrypoint("index.ts");

if ($entrypoint) {
    ["url" => $url, "hash" => $hash] = $entrypoint;
    echo "<script type='module' src='$url' crossorigin integrity='$hash'></script>" . PHP_EOL;
}

foreach ($vm->getImports("index.ts", false) as $import) {
    ["url" => $url] = $import;
    echo "<link rel='modulepreload' href='$url' />" . PHP_EOL;
}

foreach ($vm->getStyles("index.ts") as $style) {
    ["url" => $url, "hash" => $hash] = $style;
    echo "<link rel='stylesheet' href='$url' crossorigin integrity='$hash' />" . PHP_EOL;
}