CLI
./vendor/bin/tailwindphp는 필수 Node.js 없이 사용할 수 있는 PHP 포트입니다. --map(@tailwindcss/cli)를 제외하면 동일한 빌드 옵션을 사용하지만 콘텐츠 검색 방식은 다릅니다. What the CLI scans를 참고하세요. composer require tailwindphp/tailwindphp 후 바이너리가 vendor/bin/에 연결됩니다.
PHP에서 런타임에 CSS만 필요하다면 API를 사용하세요. CLI는 스타일시트를 디스크에 기록하는 빌드 단계 워크플로우용입니다.
빠른 시작
# 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 --minify
옵션
tailwindphp [-i input.css] [-o output.css] [--watch] [options…]
긴 옵션은 공백이나 =를 구분자로 사용할 수 있습니다: --input ./src/app.css, --output=./dist/styles.css 및 --cwd /path/to/project. 짧은 옵션은 다음 인수를 받습니다(-i ./src/app.css). -i - 및 --input -은 stdin을 읽습니다. 입력, 출력 또는 작업 디렉터리 값이 없으면 오류와 함께 종료됩니다.
| 옵션 | 설명 | 기본값 |
|---|---|---|
-i, --input |
입력 CSS 파일; --input=-는 stdin에서 읽음 |
@import "tailwindcss" |
-o, --output |
출력 파일 | - (stdout) |
-w, --watch |
변경 사항을 감시하고 필요할 때 다시 빌드 | — |
-m, --minify |
출력을 최적화하고 압축 | — |
--optimize |
압축 없이 최적화하여 출력을 읽기 쉽게 유지 | — |
--cwd |
현재 작업 디렉터리 | . |
-h, --help |
사용법 정보 표시 | — |
-V, --version |
버전 출력 | — |
-v, --verbose |
빌드 실패 시 스택 추적 출력 | — |
--output이 -(기본값)이면 컴파일된 CSS가 stdout에 기록되므로 다른 곳으로 파이프할 수 있습니다. 진행 메시지(버전 배너 및 Done in …ms)는 stderr로 출력됩니다.
@tailwindcss/cli와 달리 --map 옵션은 없습니다. TailwindPHP는 소스 맵을 생성하지 않습니다.
입력 CSS
Tailwind 가져오기, 테마, 지시문을 사용해 app.css을 만드세요:
@import "tailwindcss";
@theme {
--color-brand: #3b82f6;
}
CLI이 스캔하는 항목
CLI은 파일 소스를 입력 CSS 파일 기준으로 해석합니다:
- 하나 이상의 양수
@source경로가 있는 경우, 일치하는 파일만 스캔합니다. 디렉터리는 재귀적으로 탐색하며, 글로브는*,**,?, 문자 클래스 및 중괄호 그룹을 지원합니다. - **
@source not "…"**는 지시문 순서와 관계없이 일치하는 파일을 스캔과 감시 대상에서 제외합니다. - 양수 파일 소스가 없는 경우, CLI는 작업 디렉터리(
--cwd)를 재귀적으로 스캔하고 제외 항목을 적용합니다. 자동 스캔은.git,vendor및node_modules디렉터리를 건너뜁니다. 명시적 소스에는 종속 항목을 포함할 수 있습니다..gitignore은 참조하지 않습니다. @source inline("…")및 **@source not inline("…")**는 컴파일러를 통해 후보를 추가하고 제거합니다.
디렉터리 및 글로브 스캔은 php, html, htm, twig, blade.php, vue, jsx, tsx, svelte, astro 및 mdx 파일을 읽습니다. 명시적 파일 경로에는 다른 확장자를 지정할 수 있습니다. 클래스 이름은 class 및 className 속성과 정적 ->class('…') 또는 ?->class('…') 메서드 호출에서 가져오며, tw::extractCandidates()와 동일합니다. 다른 PHP 또는 JavaScript 문자열에는 @source inline("…")을 사용하세요.
/* src/app.css: scans templates/, excluding templates/legacy/ */
@import "tailwindcss";
@source "../templates/**/*.html";
@source not "../templates/legacy";
지시문 구문과 not 및 inline() 형식은 @source을 참조하세요.
예시
# Build from an input file
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/project
CLI은 출력 디렉터리가 없으면 생성하며, 입력 파일이 없거나 입력 경로와 출력 경로가 같으면 오류와 함께 종료합니다. 감시 모드에서는 입력 파일과 스캔된 파일을 500ms마다 확인하고, 파일이 변경되거나 새 파일이 나타나면 다시 빌드합니다.
전역 설치
어디서나 tailwindphp을 사용할 수 있도록 전역으로 설치하세요:
composer global require tailwindphp/tailwindphp
# Now available globally
tailwindphp -i ./src/app.css -o ./dist/styles.css