secra / caching-proxy
Converts a bunch of .css/.js files to one minified file and precompress them with gzip. Rewrite all relative path of ressources in css files.
v1.0.0
2023-01-19 10:36 UTC
Requires
- php: >=7.2
- ext-zlib: *
Requires (Dev)
- mikey179/vfsstream: 1.6.*
- phpunit/phpunit: ~8.5
- squizlabs/php_codesniffer: 2.*
This package is auto-updated.
Last update: 2024-12-19 15:24:05 UTC
README
Caching Proxy Class
The CachingProxy include css and js files in other php scripts and build a path to the files, with an timestamp of the last modification in it.
Main features are
- detect last version of .css and .js Source files
- detect .min version of .css and .js files
- combine all .css and .js files to one cached file
- auto create gzip version of cached file
- depend on mod rewrite and browser, deliver precompressed files
- debugmode for development and native, unmodified inclusion of files
Usage
For .css files use the following code in the head of your webpage. The usage for .js should be obvious.
// set the path to you webserver document root most of the time $_SERVER["DOCUMENT_ROOT"]
// and in 2. parameter the path, were you would like to store your cached files absolut from document root
$css_cache = new \secra\CachingProxy\CssCachingProxy($_SERVER["DOCUMENT_ROOT"], "/path/to/css/cache");
// Add some files
$css_cache->addFile("/path/to/file1.css");
$css_cache->addFile("/path/to/file2.css");
// Do the packing work and print the html into the head
echo $css_cache->getIncludeHtml();
Demo page
The /demo folder contain a sample webpage with the CSS and Javascript.
Changelog
###Version 1.0 (04. Jan 2021)
- Upgrade PHP Version
- Switch to docker for local demo
###Version 0.2 (18. July 2014)
- Rewrite relative path of ressources in css files
###Version 0.1 (16. February 2014)
- Add Composer Support
- PSR-4 compatible
- EditorConfig Support
- Add Licence Text
- Add usage example in readme
Developer notes
See Developer_Info.md under folder vagarnt-vm