@jts-studios/vite-plugin-php
v1.2.0
Published
Vite plugin for PHP projects — hot reload, HTML minification, and PHP build integration.
Maintainers
Readme
@jts-studios/vite-plugin-php
vite-plugin-php is an all-in-one solution for PHP projects with Vite.
How It Works
The plugin automatically manages your PHP workflow across three phases:
- Dev server: Automatically starts a PHP server, picks an available port, proxies requests to it, and injects the Vite HMR client.
- Hot update — triggers full-page reloads on
.phpchanges and CSS hot-swaps on stylesheet changes - Build — processes each PHP entry: minifies HTML, restores tokenised PHP blocks from
.jsonfragments, outputs final.phpfiles todist/
Installation
npm install @jts-studios/vite-plugin-phpUsage
// vite.config.js
import { PHP } from "@jts-studios/vite-plugin-php"
export default {
plugins: [
PHP({
entries: ["pages/index.php", "pages/about.php"],
verbose: false,
minifyHtml: true,
hotReload: true,
}),
],
}Options
| Option | Type | Default | Description |
|---|---|---|---|
| entries | string[] | required | PHP entry files or folders to process |
| verbose | boolean | false | Enable detailed build logging |
| minifyHtml | boolean | true | Minify HTML output via html-minifier-terser |
| hotReload | boolean | true | Enable hot reload for PHP and CSS changes |
| autoStartPhp | boolean | true | Start the PHP built-in server automatically in dev |
| phpHost | string | "127.0.0.1" | Host used by the auto-started PHP server |
| phpPort | number | auto (starts at 3000) | Port for PHP server; if omitted, first free port is chosen |
| phpCommand | string | "php" | PHP executable command used to start the server |
