Develop with PHP (components, includes) → Build to static HTML → Deploy anywhere.
npm install
npm run dev:allOpen: http://localhost:8000
npm run buildOutput: dist/ folder (static HTML + optimized assets)
Push to main → Builds automatically → Deploys to Netlify
Setup:
- Add GitHub Secrets:
NETLIFY_AUTH_TOKEN(from Netlify user settings)NETLIFY_SITE_ID(from site settings)
- Push to main
- Done! ✅
npm run deploy├── index.php # Pages (use PHP includes)
├── pages/*.php # More pages
├── components/*.php # Reusable components
├── src/
│ ├── css/ # SCSS styles
│ ├── js/ # JavaScript
│ └── assets/ # Images, fonts
└── dist/ # Built site (after npm run build)
├── *.html # Static HTML
└── assets/ # Optimized CSS/JS
| Command | Description |
|---|---|
npm run dev:all |
Start dev servers (Vite + PHP) |
npm run build |
Build static site |
npm run deploy |
Build + deploy to Netlify |
npm run preview |
Preview production build |
<?php require_once 'vite-helper.php'; ?>
<!doctype html>
<html>
<head>
<?php viteClient(); ?>
<?php viteEntry('src/css/style.scss'); ?>
<title>Page Title</title>
</head>
<body>
<?php include 'components/header.php'; ?>
<main>Your content</main>
<?php include 'components/footer.php'; ?>
<?php viteEntry('src/js/main.js'); ?>
</body>
</html>Development:
- PHP files with includes/components
- Vite dev server for HMR
- Fast development workflow
Production:
- PHP → HTML conversion
- CSS/JS optimized & minified
- Pure static site output
- Deploy anywhere (no PHP needed)
- Node.js 20+
- PHP 7.4+ (dev only)
Best of both worlds: PHP flexibility + static site speed! 🚀