1
0
mirror of https://github.com/mrclay/minify.git synced 2025-02-23 08:25:12 +01:00
minify/README

69 lines
2.7 KiB
Plaintext
Raw Normal View History

2008-02-29 01:53:41 +00:00
WARNING!
2008-02-28 18:42:56 +00:00
2008-02-29 01:53:41 +00:00
SVN contains early work on version 2 of Minify and should be considered
"alpha" quality. For production-tested code, please choose an
earlier release from: http://code.google.com/p/minify/downloads/list
2008-02-28 18:42:56 +00:00
2008-02-29 01:53:41 +00:00
The documentation at http://code.google.com/p/minify/ applies to those
releases.
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
SETUP
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
Minify is a library of files inside the "lib" directory. Wherever you
place "lib", it needs to be in your include_path, and should be
access-protected or outside of DOCUMENT_ROOT.
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
TESTING
2008-02-28 21:14:06 +00:00
1. Place the "web" directory somewhere in DOCUMENT_ROOT.
2. Edit "config.php" to manually add "lib" to the include_path.
3. To enable server-side caching, set $minifyCachePath to a PHP-writeable directory
4. Visit http://yourdomain.com/path/to/web/examples/1/
This page should contain 3 "PASS"es. It may take a few seconds to minify jQuery!
5. Visit http://yourdomain.com/path/to/web/test/test_all.php
This will run all unit tests. You can call the tests individually to see
more details.
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
MINIFY OVERVIEW
2008-02-28 21:14:06 +00:00
Minify is an HTTP content server. It compresses sources of content
(usually files), combines the result and serves it with appropriate
2008-02-29 01:53:41 +00:00
HTTP headers. These headers can usually allow clients to perform
conditional GETs (serving content only when clients do not have a valid
cache) or tell clients to cache the file until a given date/time.
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
Minify works with Minify_Source objects. These usually represent a file
on disk, but a source can also be content on hand or from a database.
Sources with known "last modified" timestamps allow Minify to implement
conditional GETs.
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
You configure Minify via a Minify_Controller object. The controller
supplies the sources and default options to serve a request,
2008-02-29 01:53:41 +00:00
determining how it's to be responded to. Several controllers are
supplied with Minify, but it's also fairly easy to write your own. E.g.
a controller could emulate v1.x of minify.php.
To use an existing controller, you call Minify::serve(), passing it:
1. the name of your controller of choice (without the "Minify_Controller"
prefix) or a custom controller object subclassed from Minify_Controller_Base.
2. a combined array of controller and Minify options. Eg.:
2008-02-29 01:53:41 +00:00
// serve a minified javascript file and tell clients to cache it for a
// year
Minify::serve('Files', array(
'files' => array('/path/to/file1.js', '/path/to/file2.js')
,'setExpires' => (time() + 86400 * 365)
));
2008-02-28 21:14:06 +00:00
The above creates an instance of Minify_Controller_Files, which creates
source objects from the 'files' option, and supplies other default options.
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
MINIFY USAGE
2008-02-28 21:14:06 +00:00
2008-02-29 01:53:41 +00:00
Example 1 shows an example of using Minify to serve both the HTML and
external CSS and JS files.