CLI
./vendor/bin/tailwindphp is a 1:1 port of @tailwindcss/cli — same options, same behavior, no Node.js required. After composer require tailwindphp/tailwindphp, the binary is linked into vendor/bin/.
If you only need CSS at runtime from PHP, use the API instead — the CLI is for build-step workflows that write a stylesheet to disk.
Quick start
# Build CSS from an input file
./vendor/bin/tailwindphp -i ./src/app.css -o ./dist/styles.css
# Watch for changes and rebuild
./vendor/bin/tailwindphp -i ./src/app.css -o ./dist/styles.css --watch
# Build minified for production
./vendor/bin/tailwindphp -i ./src/app.css -o ./dist/styles.css --minifyOptions
tailwindphp [--input input.css] [--output output.css] [--watch] [options…]| Option | Description | Default |
|---|---|---|
-i, --input | Input CSS file | @import "tailwindcss" |
-o, --output | Output file | - (stdout) |
-w, --watch | Watch for changes and rebuild as needed | — |
-m, --minify | Optimize and minify the output | — |
--optimize | Optimize the output without minifying | — |
--cwd | The current working directory | . |
-h, --help | Display usage information | — |
When --output is - (the default), the compiled CSS is written to stdout, so you can pipe it elsewhere.
Input CSS
Create an app.css with your Tailwind import and a @source directive telling TailwindPHP where to scan for classes:
@import "tailwindcss";
@source "./templates"; /* Directory to scan for classes */@source accepts directories, glob patterns, and multiple entries:
@import "tailwindcss";
@source "./templates"; /* a directory */
@source "./src/**/*.php"; /* a glob */
@source "./resources/views"; /* add as many as you need */See @source for the full directive reference, including not and inline() forms.
Examples
# Build from CSS with a @source directive
tailwindphp -i ./src/app.css -o ./dist/styles.css
# Build minified for production
tailwindphp -i ./src/app.css -o ./dist/styles.css -m
# Watch mode with minification
tailwindphp -i ./src/app.css -o ./dist/styles.css -w -m
# Run against a different working directory
tailwindphp -i app.css -o dist/styles.css --cwd=/path/to/projectThe CLI creates the output directory if it does not exist, and exits with an error if the input file is missing or the input and output paths are identical.
Global installation
Install globally to use tailwindphp from anywhere:
composer global require tailwindphp/tailwindphp
# Now available globally
tailwindphp -i ./src/app.css -o ./dist/styles.cssSee Getting Started for project setup and the API for runtime CSS generation from PHP.
Performance & Testing
PHP-specific optimizations that preserve identical output, and the extraction-based test loop that keeps the port in lockstep with TailwindCSS.
API
The full TailwindPHP\tw static API — generate, compile, properties, computed values, theme inspectors, caching — plus the reusable TailwindCompiler instance.