A Vite plugin that enables processing PHP files within Vite's build pipeline, leveraging Vite's fast dev server, HMR, and build tooling for PHP-heavy projects. Currently at v2.0.4, actively maintained with regular bug fixes and performance improvements. Key differentiators: integrates PHP directly into Vite's module graph, supports multiple PHP entry points, provides browser auto-refresh on PHP changes, and works alongside traditional frontend assets. Unlike other solutions, it does not require a separate PHP server during development for asset handling.
npm install vite-plugin-phpVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config with PHP plugin and a PHP entry point showing vite() helper integration.
Update your config: rename phpPath to phpBinary, and adjust nested options per documentation.
Use import syntax instead of require.
Set phpBinary explicitly or ensure PHP is in PATH.
Always use the <?= vite('entry.js') ?> pattern.Install PHP or set phpBinary in plugin config: php({ phpBinary: '/usr/bin/php' })Fix the PHP syntax error. The plugin expects valid PHP code in entry files and files included via vite() helper.
Change import to: import php from 'vite-plugin-php'
Ensure the PHP file is in the plugin's entry list and the plugin is added to vite.config.