PHPackages                             psychowico/assets-compiler - 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. psychowico/assets-compiler

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

psychowico/assets-compiler
==========================

Zend framework css and js combine and minify module

1.0.0(12y ago)21592[2 issues](https://github.com/psychowico/AssetsCompiler/issues)BSD-3-ClausePHPPHP &gt;=5.3.3

Since Dec 28Pushed 9y ago2 watchersCompare

[ Source](https://github.com/psychowico/AssetsCompiler)[ Packagist](https://packagist.org/packages/psychowico/assets-compiler)[ Docs](http://github.com/psychowico/AssetsCompiler)[ RSS](/packages/psychowico-assets-compiler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

\#AssetsCompiler

AssetsCompiler is module for ZF2 that help you managment your project static files. For now it is responsible for combine and minifying CSS and Javascript files. It is in development state and in near future more features will be released.

It provides zend console route script to compile selected files as bundles and view helpers to automatically attaching bundles in your views. It can add files md5 to bundle file names - to avoid browser file caching after changes.

As **bundle** we understack pack of js/css files. In development mode all files from bundle are including to your site separately. In production - they are contacted and minimized to single bundle file and included in this way.

Installation
------------

[](#installation)

1. Add `"psychowico/assets-compiler": "dev-master"` to your `composer.json` file and run `php composer.phar update`.
2. Add *AssetsCompiler* to your `config/application.config.php` file under the modules key.

Minifier
--------

[](#minifier)

Minifier classes provides zend console route script to compile selected files as bundles and view helpers to automatically attaching bundles in your views. It can add files md5 to bundle file names - to avoid browser file caching after changes.

### Configuration

[](#configuration)

To make Minifier working you need declare your bundles lists and set your local directories. Easiest way is copy `.../Minifier/config/minifier.global.php.dist` file to `config/autoload/minifier.global.php`. Next you need proper fill configuration data inside `minifier` key. Most options have default values, you can found their in `.../Minifier/config/module.config.php` file.

- *js\_adapter* - js adapter configuration array

    - *class* - adapter class (probably from *\\AssetsCompiler\\Minifier\\Adapter\\*)
    - *options* - array of adapter options, you can read about them in "Adapters" section
- *css\_adapter* - css adapter configuration array, like above
- *development\_mode* - boolean flag, if true our view helper will attach all files included in bundles, one by one. If setted to true - it will attach one combined file per bundle. Default is true.
- *persistent\_file* - bundles need store some data, it is done in xml file, you can specify where this file will be save, relative to project root. Not required. By default it use *"./data/minifier/config.xml"* file.
- *public\_dir* - you can define your public directory here, relative to project root. Not required, By default it use *"./public"*.
- *bundles* - bundles configuration, can have *js* and *css* keys

Both, *js* and *css* configurations you can define by using this options:

- *output\_dir* - output directory where bundles of this type will be saved, relative to project public directory
- *list* - list of bundles

List of bundles is a array where key is the bundle name, value is options array:

- *filename* - the bundle output filename pattern - by default it is '%s-%s'. First argument is the bundle name, second - bundle included files md5 value. Not required.
- *sources* - array of the bundle included files, pathes relative to project public directory

### How to use

[](#how-to-use)

If you had configured your bundles and need combine and minify them just run your *public/index.php* file with cmds:

`php index.php minify`

It will do all job. To make it more easier and more intuitive you can create *bin* folder in your project root directory. There create `minify` file with the following content:

```
#!/usr/bin/php
