# bundle-phu
**Repository Path**: shrekuu/bundle-phu
## Basic Information
- **Project Name**: bundle-phu
- **Description**: A set of Zend Framework view helpers that automagically bundle, minify, and compress your javascript and css.
- **Primary Language**: PHP
- **License**: BSD-2-Clause
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-10-21
- **Last Updated**: 2021-11-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
bundle-phu
==========
Bundle-phu is a set of [Zend Framework][1] view helpers that automagically concatenate, minify, and gzip
your javascript and stylesheets into bundles. This reduces the number of HTTP requests to your servers as
well as your bandwidth.
Bundle-phu is inspired by [bundle-fu][2] a [Ruby on Rails][3] equivalent.
Bundle-phu automatically detects modification to your JS/CSS and will regenerate bundles automatically.
Minification can be done using either an external program such as the [YUI compressor][4] or using
PHP via callback.
Compression is done using PHP's [gzencode()][5] function.
### Before
### After
Installation
============
1. Place the BundlePhu directory somewhere in your include_path:
your_project/
|-- application
|-- library
| `-- BundlePhu
|-- public
2. Add the BundlePhu view helpers to your view's helper path, and configure the helpers:
addHelperPath(
PATH_PROJECT . '/library/BundlePhu/View/Helper',
'BundlePhu_View_Helper'
);
$view->getHelper('BundleScript')
->setCacheDir(PATH_PROJECT . '/data/cache/js')
->setDocRoot(PATH_PROJECT . '/public')
->setUrlPrefix('/javascripts');
$view->getHelper('BundleLink')
->setCacheDir(PATH_PROJECT . '/data/cache/css')
->setDocRoot(PATH_PROJECT . '/public')
->setUrlPrefix('/stylesheets');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setView($view);
return $view;
}
}
3. Ensure your CacheDir is writable by the user your web server runs as
4. Using either an Alias (apache) or location/alias (nginx) map the UrlPrefix to CacheDir.
You can also do this using a symlink from your /public directory.
e.g. /public/javascripts -> /../data/cache/js
Usage
=====
As both these helpers extend from the existing HeadScript and HeadLink helpers in [Zend Framework][1],
you can use them just as you do those.
$this->bundleScript()->offsetSetFile(00, $this->baseUrl('/js/jquery.js')) ?>
$this->bundleScript()->appendFile($this->baseUrl('/js/foo.js')) ?>
[1]: http://framework.zend.com/
[2]: http://code.google.com/p/bundle-fu/
[3]: http://rubyonrails.org/
[4]: http://developer.yahoo.com/yui/compressor/
[5]: http://php.net/gzencode