1. Go to this page and download the library: Download davidhirtz/yii2-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/ */
davidhirtz / yii2-vite example snippets
'components' => [
'vite' => [
'baseUrl' => '@web/dist',
'basePath' => '@root/web/dist', // `build.outDir`, read for stylesheets to inline
'manifestPath' => '@root/web/dist/.vite/manifest.json',
'useDevServer' => YII_ENV_DEV,
'checkDevServer' => true,
'devServerUrl' => 'http://localhost:5173',
'devServerInternalUrl' => null, // where PHP reaches the dev server, if not at `devServerUrl`
'devServerTimeout' => 0.1, // seconds
'inlineCssMaxSize' => 0, // bytes, uncompressed; `0` links every stylesheet
'preloadJsModule' => true, // a `modulepreload` link for a `registerJsModule()` entry
],
],
use Hirtz\Vite\Vite;
// The entry's script tag, its stylesheets and a `modulepreload` link for every chunk it imports
Vite::current()->register('resources/js/app.ts');
// A stylesheet entry, with options for the link tags
Vite::current()->register('resources/css/print.scss', ['media' => 'print']);
// Options of the script tag
Vite::current()->register('resources/js/app.ts', jsOptions: ['position' => View::POS_HEAD]);
// Imported by the page's module script, its default export called with the arguments (`View::registerJsModule()`).
// A `modulepreload` link for the entry starts its request from the head, `'preloadJsModule' => false` leaves it out
Vite::current()->registerJsModule('resources/js/gallery.ts', ['selector' => '#gallery']);
// The URL of any manifest entry, an image
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.