1. Go to this page and download the library: Download josbeir/cakephp-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/ */
josbeir / cakephp-vite example snippets
public function initialize(): void
{
parent::initialize();
$this->loadHelper('CakeVite.Vite');
}
> // Uses config default (src/main.js) in development
> $this->Vite->script();
>
> // Override for this specific call (works in dev and production)
> $this->Vite->script(['files' => ['src/admin.js']]);
>
return [
'CakeVite' => [
'devServer' => [
// Development server URL
'url' => env('VITE_DEV_SERVER_URL', 'http://localhost:3000'),
// Hostname hints for development mode detection
'hostHints' => ['localhost', '127.0.0.1', '.test', '.local'],
// Default entries for development mode
'entries' => [
'script' => ['src/main.js'],
'style' => ['src/style.css'],
],
],
'build' => [
// Path to Vite's manifest.json
'manifestPath' => WWW_ROOT . 'manifest.json',
// Output directory (relative to webroot)
'outDirectory' => false, // or 'dist', 'build', etc.
],
// Modulepreload support for faster loading (production only)
// Options: 'none', 'link-tag'
'preload' => env('VITE_PRELOAD_MODE', 'link-tag'),
// Persistent caching (production performance optimization)
'cache' => [
'config' => env('VITE_CACHE_CONFIG', false), // CakePHP cache config name
'development' => false,
],
// Force production mode (ignores environment detection)
'forceProductionMode' => false,
// Plugin name for loading plugin assets (null for app assets)
'plugin' => null,
// Cookie/query parameter name to force production mode
'productionModeHint' => 'vprod',
// View block names for script and CSS tags
'viewBlocks' => [
'script' => 'script',
'css' => 'css',
],
],
];