Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 1.87 KB

readme.md

File metadata and controls

66 lines (47 loc) · 1.87 KB

CzProject\CssTools

Build Status Downloads this Month Latest Stable Version License

CSS tools for PHP.

Donate

Installation

Download a latest package or use Composer:

composer require czproject/css-tools

CzProject\CssTools requires PHP 7.4 or later.

Usage

CSS compiler

Expands @import rules in file.

$compiler = new CzProject\CssTools\CssCompiler;
$compiler->compileFile(__DIR__ . '/styles.css'); // overwrite styles.css with compiled version
$compiledStyles = $compiler->processFile(__DIR__ . '/styles2.css');
$compiledStyles = $compiler->processContent(
	'@import "mystyles.css";',
	$stylesheetsRootDirectory
);

CSS generator

$file = new CzProject\CssTools\CssFile;
$file->addRule('.button', [
	'color' => CssTools\Color::hex('#F8A'),
	'font-size' => CssTools\Number::px2rem(48),
	'background-color' => NULL,
]);

echo $file->render();

CSS minifier

$minifier = new CzProject\CssTools\CssMinifier;
$result = $minifier->minify("body {
	color: #333;
	background: #fff;
}");
var_dump($result); // Output: body{color:#333;background:#fff}

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/