phpLivePacker is a PHP based Open Source on-the-fly CSS/JS file packer with browser conditions.
Combines and minifies multiple input source files to one output file on the fly.
Delivers different CSS/JS file combinations depending on a browser, browser engine, browser version or operating system. It is even possible to combine and negotiate single conditions.
e.g., Deliver a file only if the browser is Internet Explorer and its version number is lower or equal 9. Deliver a file only if the browser is not Firefox and the operating system is Windows.
Generated output files and browser detection results are cached for an optimum in performance.
CSS/JS files are minified and gzipped before delivered to the browser, for minimum file size.
phpLivePacker protects your development knowhow by removing all comments from CSS/JS files before delivered to the client.
Generate an unlimited number of different sets of CSS/JS files e.g. one for the start page and another for the subpage.
Directly include small icons as Base64 encoded strings into your CSS.
Generate JS or JSON-Arrays for preloading all images included in your CSS files automatically.
phpLivePacker and its file sets are configured via simple and well-documented PHP INI files.
You can disable caching and minifying by domains or IP addresses for development.
phpLivePacker is included like regular CSS/JS files into your HTML header, thus it can be used from simple HTML templates through to large CMS solutions.
phpLivePacker‘s caching system is fully integrable via extensions into TYPO3 and WordPress.
Works on Linux and Windows environments and requires an Apache HTTP Server (with mod_rewrite) and at least PHP 5.3.
phpLivePacker is published under the Apache License Version 2.0 with the target to be used and modified.
phpLivePacker allows me to use my own fragmented and well-structured CSS/JS file and folder structure. But the best thing about it is, that I don't need strange CSS hacks anymore.
phpLivePacker is published under the Apache License Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt).
Download the newest version of phpLivePacker, extract it and copy the whole folder into your template directory. Make sure the cache directory is writeable for PHP to make the internal caching system work. If you manage your web project with a version control system like SVN or Git, make sure to exclude files within the cache directory from version control. If you want to include CSS and JS files via nice URLs, make sure mod_rewrite is enabled and .htaccess files are allowed for the phpLivePacker directory. You can use the included admin interface to get more information and check if the requirements are met (Call the phpLivePacker directory in your web browser and choose admin interface from the visible start page).
You can control caching, minifying and development features by the basic phpLivePacker configuration, which you can find under conf/phplivepacker.ini in the phpLivePacker directory. All configuration files within phpLivePacker are standardised PHP INI files and well commented. You can use the included admin interface to check if your settings meet the recommendations (Call the phpLivePacker directory in your web browser and choose admin interface from the visible start page).
All CSS/JS files which should be delivered are organized within so-called sets. These file sets are defined via PHP INI configuration files in the directory conf/sets/. The name of the set is defined by the file name of the PHP INI file, so make sure to use web safe characters. The default set used - if phpLivePacker is called without the set parameter - is predefined as default.ini. For each set, you are able to organize your CSS/JS files within different sections. There are the sections safe and basic and furthermore an unlimited number of browser conditions. All files placed within the section safe will be always included but never get minified or cleaned up - the best place for already minified JS libraries. Just like the section safe the section basic is always included regardless of detected browser and operating system but will get cleaned up and minified. The different browser and operating system conditions are well documented in the default.ini file and will allow you to add CSS/JS files only if a specified browser, browser version, browser engine or operating system is detected. It is also possible to combine or negotiate different conditions.
[safe] files always get included, but will not be minified or cleaned up (use for already minified sources)
[base] files always get included
[<!>browser <operator> version (<!>os)]
[<!>engine (<!>os)]
samples:
operator: =, !=, <, <=, >, >=
browser: ie, firefox, opera, safari, chrome or unknown
engine: webkit, gecko, presto, trident (not in combination with version number)
version: version number (minor: 3.5, major: 4)
os: windows, osx, linux, ios, android, symbian, blackberry, wince, windowsphone or unknown
combine conditions (OR): [condition1,condition2,condition3]
phpLivePacker generated CSS/JS files are included like every other CSS/JS file into the html header. The syntax is as follows:
<style/script>[_<set>][_v<counter>].<css/js>
<style/script>: Use the filename style to get CSS files and script to get JS files.
[_<set>]: Define the needed set, if not specified the default set is returned.
[_v<counter>]: An optional counter to override browser caching on the client by changing the file name.
<css/js>: Use appropriate file extension for CSS or JS resources.
File names are following these examples:
If the Apache HTTP Server module rewrite is not available or deactivated for security reasons, it is also possible to call the phpLivePacker script via parameters.
phplivepacker.php?type=<css/js>&set=<set>
phpLivePacker was created to make web development much more comfortable. The integrated browser detection and different debug settings will allow developers to code efficiently. So you can disable minifying, combining, code clean up or even override browser detection values for easy debugging. Make sure to exclude your development systems by domains or IP addresses from caching. phpLivePacker rewrites relative paths within your CSS files to deliver images even after combining single files from different directories.
Use the phpLivePacker TYPO3 extension for simple cache management within the TYPO3 backend.
<INCLUDE_TYPOSCRIPT: source="FILE: fileadmin/typoscript/constants/phplivepacker.ts">
page.includeCSS {
# default css file
file1 = {$protocol}://{$host}/{$phplivepackerPath}style_v{$phplivepackerVersion}.css
file1.external = 1
}
page.includeJS {
# default js file
file1 = {$protocol}://{$host}/{$phplivepackerPath}script_v{$phplivepackerVersion}.js
file1
}
If you have changed CSS or JS files, you can quickly clear the phpLivePacker cache via the new cache management option Clear phpLivePacker cache within the TYPO3 backend. Due to TYPO3 security restrictions, the extension is not able to clear the page content cache. Hence do not forget to clear the front end cache manually after clearing the phpLivePacker cache (because the virtual version number provided in the CSS/JS file path increased).
Use the phpLivePacker WordPress plugin for simple cache management within the WordPress admin interface.
<?php
require_once(get_template_directory() . '/phplivepacker.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo htmlspecialchars(home_url() . '/' . PHPLIVEPACKER_PATH); ?>style_v<?php echo PHPLIVEPACKER_VERSION; ?>.css" />
<script language="javascript" src="<?php echo htmlspecialchars(home_url() . '/' . PHPLIVEPACKER_PATH); ?>script_v<?php echo PHPLIVEPACKER_VERSION; ?>.js" type="text/javascript"></script>
If you have changed CSS or JS files, you can quickly clear the phpLivePacker cache via the new cache management option Clear phpLivePacker cache within the WordPress admin interface.