PHP code example of phpsoftbox / vite

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

    

phpsoftbox / vite example snippets


$vite = new \PhpSoftBox\Vite\Vite(
    manifestPath: __DIR__ . '/public/build/manifest.json',
    hotFile: __DIR__ . '/public/hot',
    devServer: 'https://vite.domain.local',
    environment: 'dev',
    buildBase: '/build',
    ssrUrl: 'http://node:13714/render',
    ssrEntry: 'resources/js/ssr.tsx',
    ssrTimeout: 2.0,
    dev: null, // явный флаг dev-режима; null — определить по environment
);

echo $vite->tags('resources/js/app.tsx');

echo $vite->tags('resources/js/app.tsx');

echo $vite->tags(['resources/js/app.tsx', 'resources/css/admin.css']);
// ...
// <link rel="stylesheet" href="/build/assets/admin.789.css">

if ($vite->ssrEnabled()) {
    $renderer = new HttpSsrRenderer(
        url: $vite->ssrUrl(),
        timeout: $vite->ssrTimeout(),
    );
}