Similar to the JSMin port I did, this is a CSS minification library ported from the awesome Minify App. Basically, I took the Minify_CSS component class and added a simple wrapper class to make it play nice with CodeIgniter.
The library expects a string and returns a string.
You load the library as normal:
Minify a string like so:
$this->cssmin->minify( file_get_contents('styles.css') );
There are two options:
Boolean flag for preserving comments. Only comments starting with /*! are preserved. Defaults to true.
String that will be prepended to all relative URIs in import/url declarations. Defaults to null.
The options can either be set globally using the config function:
$cssmin_options = array(
Or on individual calls to the minify function:
$this->cssmin->minify( $string, FALSE, $path );
Global settings override settings in individual calls.
Note: just like the jsmin library, cssmin is PHP5.