Integrations

Set up Master CSS in PHP

Guide to setting up Master CSS in plain PHP or CodeIgniter projects.

Use static rendering when PHP templates contain complete class strings and you want Vite to build a generated CSS asset before PHP serves the page.

Open your project

Start from the PHP or CodeIgniter project root.

cd my-php-appnpm init -y

Install Vite and Master CSS

Install Vite and the Master CSS Vite integration.

npm install -D vite @master/css.vite@rc

Configure Vite

Build static CSS into public/assets.

import { defineConfig } from 'vite'import masterCSS from '@master/css.vite'export default defineConfig({    plugins: [        masterCSS({ mode: 'static' })    ],    build: {        outDir: 'public/assets',        emptyOutDir: true,        rollupOptions: {            input: 'resources/main.ts',            output: {                entryFileNames: 'app.js',                assetFileNames: 'app[extname]'            }        }    }})

Create the asset entry

Import Master CSS and scan PHP files where complete class strings are written.

import './app.css'
@import "@master/css";@source "../app/**/*.php";@source "../public/**/*.php";

Hello world

Load the generated CSS and style your first PHP template.

localhost

Hello World

<link rel="stylesheet" href="/assets/app.css"><h1 class="m:2xl italic font:5xl font:heavy text:neutral">    Hello World</h1>

For CodeIgniter, scan app/Views/**/*.php and load /assets/app.css with your normal asset helper. Static rendering depends on complete class strings in scanned source files.


© 2026 Aoyue Design LLC.MIT License
Trademark Policy