vite-plugin-php
Use Vite's speed, HMR and ecosystem to build with PHP.
// vite.config.js
import { defineConfig } from 'vite';
import usePHP from 'vite-plugin-php';
export default defineConfig({
plugins: [usePHP()],
});
Vite-powered PHP
Keep writing PHP while Vite handles assets, transforms, environment variables and hot module replacement.
Start buildingFlexible configuration
Point to a custom PHP binary, define multiple entry points, rewrite URLs and control PHP error reporting.
Explore optionsMulti-page routing
Use globs to register many PHP pages and let the plugin route requests and build each entry correctly.
See routingPipeline integration
Run additional Vite plugins before or after PHP processing via transformIndexHtml hooks.
Learn the pipelineWhat is vite-plugin-php?
vite-plugin-php bridges PHP and Vite. You keep your index.php entry file, server-side logic and includes, while Vite processes scripts, styles, images and environment variables just like it would for a static HTML project.
During development the plugin starts a PHP development server behind the scenes, proxies requests through Vite and streams PHP errors into the Vite console. During production builds it feeds your PHP files through the standard Vite pipeline and writes each entry to the output directory.
Where to go next
- Get Started — install the plugin and render your first PHP page.
- Configuration — every option explained with copy-paste snippets.
- Routing — how entry files map to URLs and build outputs.
- Vite Pipeline — integrate other plugins before or after PHP.
- Examples — multi-entry apps, React + PHP, external assets and more.
- Limitations — things to know about inline modules and dynamic assets.