PHPackages                             mikehaertl/packagecompressor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mikehaertl/packagecompressor

ActiveYii-extension[Utility &amp; Helpers](/categories/utility)

mikehaertl/packagecompressor
============================

packagecompressor is a Yii extension that can compress Javascript/CSS and is based on Yii's package system

1.0.5(12y ago)161293[2 PRs](https://github.com/mikehaertl/packagecompressor/pulls)MITPHPPHP &gt;=5.0.0

Since Feb 20Pushed 10y ago6 watchersCompare

[ Source](https://github.com/mikehaertl/packagecompressor)[ Packagist](https://packagist.org/packages/mikehaertl/packagecompressor)[ Docs](https://github.com/mikehaertl/packagecompressor)[ RSS](/packages/mikehaertl-packagecompressor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (6)Used By (0)

PackageCompressor
=================

[](#packagecompressor)

A Javascript/CSS compressor based on Yii's package system.

Requirements
============

[](#requirements)

- A Java runtime engine must be installed for the YUI compressor

Features
========

[](#features)

- Javascript and CSS compression of [Yii clientscript packages](http://www.yiiframework.com/doc/api/1.1/CClientScript#packages-detail)(using YUI compressor)
- Does not interfere with scripts and CSS registered outside of packages
- Automatic or manually triggered compression
- [Locking](http://www.yiiframework.com/extension/mutex) mechanism to prevent multiple concurrent compressions
- Workaround for the thundering herd problem
- Command-line maintenance script

You probably wonder, [why](http://www.yiiframework.com/extension/minscript)[yet](http://www.yiiframework.com/extension/escriptboost)[another](http://www.yiiframework.com/extension/clientscriptpacker)[compression](http://www.yiiframework.com/extension/dynamicres/)[extension](http://www.yiiframework.com/extension/extendedclientscript)[for](http://www.yiiframework.com/extension/assetcompiler)[Yii](http://www.yiiframework.com/extension/eclientscript)? The key difference is, that none of the existing solutions uses Yii's integrated [package system](http://www.yiiframework.com/doc/api/1.1/CClientScript#packages-detail)for clientscripts. With this extension you can organize all your CSS and Javascript in packages and even define dependencies among them. This may not be very useful for smaller sites (even though you still can use the compressor there, too). But it proved to be extremely helpful when you have to deal with many Javascript files and want to cluster them into a couple of minified package files.

> Note: You can even include Yii's [core scripts](https://github.com/yiisoft/yii/blob/1.1.13/framework/web/js/packages.php)in a package. Unfortunately some Zii widgets like `CListView` and `CGridView` still don't use the package system packages. But this will hopefully [be fixed](https://github.com/yiisoft/yii/issues/1033)in Yii 1.1.15.

Basic example
=============

[](#basic-example)

Packages are set up in your config file. Javascript and CSS packages must be separate. Here's an example:

```
