2.1 KiB
Minify 2
Minify 2.0.0 was released May 22, 2008 and represents an architectural redesign of Minify's code and its usage. 2.0 is built as a library of classes allowing users to easily build customized minified-file servers; or add minification, HTTP encoding, or conditional GET to existing projects.
The release includes 3 example sites to demostrate usage and unit tests you can run on your system.
Documentation
Each PHP file is documented, but, for now, the README file is the best reference for getting started with the library. This blog post may also give you some ideas.
The best place for questions is the minify Google group.
Included HTTP Classes
The two HTTP utility classes, HTTP_ConditionalGet and HTTP_Encoder, are already fairly well-tested and include a set of test pages to see how they work. On the Florida Automated Weather Network site, these are used especially in scripts that serve data to our Flash components.
Here's an example of using both to conditionally serve a text file gzipped:
$cg = new HTTP_ConditionalGet(array(
'lastModifiedTime' => filemtime($filepath)
,'isPublic' => true
));
$cg->sendHeaders();
if ($cg->cacheIsValid) {
// client cache was valid, no content needed
exit();
}
require 'HTTP/Encoder.php';
$he = new HTTP_Encoder(array(
'content' => file_get_contents($filepath)
,'type' => 'text/plain'
));
$he->encode();
$he->sendAll();