PHPackages                             kloy/assetix - 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. kloy/assetix

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

kloy/assetix
============

Boilerplate for quickly taking advantage of Assetic asset management.

0.1.1(14y ago)451[4 issues](https://github.com/kloy/assetix/issues)MITPHPPHP &gt;=5.3.0

Since Mar 20Pushed 14y ago1 watchersCompare

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

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

Assetix
=======

[](#assetix)

A simple wrapper for easily using Assetic. Provides a simple way for including assets and letting Assetic build and cache them in production.

Assetix uses [composer](http://getcomposer.org/) for including [Assetic](https://github.com/kriswallsmith/assetic). Follow the steps at [Packagist](http://packagist.org/) if you are unfamiliar with composer to get going.

Example
-------

[](#example)

```
require_once('classes/assetix.php');

use Assetix\Assetix;

// Instantiate Assetix
$assetix = new Assetix();

// Add css files to group base_css
$css = array('/css/test.css');
$assetix->css('base_css', $css);

// Add js files to group base_js
$js = array('/js/underscore.js', '/js/*');
$assetix->js('base_js', $js);

// Echo out raw compiled files
echo $assetix->css('base_css', true)."\n";
echo $assetix->js('base_js', true)."\n";

// Echo out links to compiled files
echo $assetix->css('base_css')."\n";
echo $assetix->js('base_js')."\n";

```

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

[](#installation)

Follow the instructions on [Packagist](http://packagist.org/) to add "kloy/assetix": "0.1.\*" in the require section of your composer.json file and install. Once installed run `npm install .` from the vendor/kloy/assetix/ dir. This will install the needed nodejs modules for compiling less, stylus, and coffeescript.

Available asset function
------------------------

[](#available-asset-function)

Assetix features the ability to compile many assets. All functions implement the same argument structure. This structure is `func('group', array() /* asset paths */, bool /* true for raw outputting, false for a link */)`. As you may have noticed, you can call func() without an array of assets if you just wish to get a link from a previously defined group. You may call it with a second argument of true to get the raw output of the group. The current list of asset functions is below...

- css() - normal css stylesheet
- less() - less css
- styl() - stylus css
- js() - normal javascript
- coffee() - coffee-script
- underscore() - underscore javascript templates
- handlebars() - handlebars javascript templates

How does the build process work?
--------------------------------

[](#how-does-the-build-process-work)

The assets are lazily built on the first request for them. Once built they are cached so further builds for the same asset is not needed. In a production setting you will assign a version number in the assetix config. When this version number is changed all assets are rebuilt and a new file with this version number is generated for cache busting purposes.

Assets that become css are first compiled to css, then images are embedded into the css via datauri and base64 encoding, last the assets get minimized. Assets that become js are compiled to js and minimized.

Internet Explorer Version 7 and below.
--------------------------------------

[](#internet-explorer-version-7-and-below)

IE 7 and below does not support datauri functionality used for embedding images into css. In order to work around this you can prefix 'ie\_' to a group's name. Here is an example.

`css('ie_foo', array('css/*'));`

This will cause the compiler to not use the embedcss filter which means all images will be requested as normal.

Rewriting CSS
-------------

[](#rewriting-css)

By the default all relative ../ paths are replaced with /assets/production/. To modify this behavior change $config\['css\_rewrite\_replacement'\] to use a different replacement value or $config\['css\_rewrite\_pattern'\] to use a different pattern for matching.The way the css rewrite works is the content of a css file is passed through preg\_replace. So make sure your values for $config\['css\_rewrite\_replacement'\] and $config\['css\_rewrite\_pattern'\] work properly with this function.

To modify the css rewrite on the fly you can call $assetix-&gt;set\_rewrite($replacement, $pattern);

Example:

```
$assetix->set_rewrite('\\1/foo/');
$test2 = $assetix->css('ie_base_css', array('/rewrite_css/test.2.css'), true);

```

All calls to $assetix-&gt;css will use the set replacement value for now on. To change the replacement value again just call $assetix-&gt;set\_rewrite() with new values.

To better understand how css rewrite works take a look at Assetix::\_construct() and Assetix::set\_rewrite() and follow the code back to MyCssRewriteFilter.

API
---

[](#api)

The public available APIs are described in interfaces. Currently the iAssetix and iCompiler interfaces exist. This project follows [Semantic Versioning](http://semver.org/).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

5171d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5eac3c1f7023c3d48513c44c799e9752d9db0c9f668a403f0d836cc0addf5c6e?d=identicon)[kloy](/maintainers/kloy)

---

Tags

compressionassetsminification

### Embed Badge

![Health badge](/badges/kloy-assetix/health.svg)

```
[![Health](https://phpackages.com/badges/kloy-assetix/health.svg)](https://phpackages.com/packages/kloy-assetix)
```

###  Alternatives

[kriswallsmith/assetic

Asset Management for PHP

3.7k48.9M161](/packages/kriswallsmith-assetic)[assetic/framework

Asset Management for PHP

1001.4M20](/packages/assetic-framework)[konstantin-kuklin/assetic-static-gzip-bundle

Provide static gzip compression for css,js files via AsseticBundle

149.2k1](/packages/konstantin-kuklin-assetic-static-gzip-bundle)[toopay/assetic-minifier

Assetic Filter for pure PHP JS and CSS minification

1356.8k3](/packages/toopay-assetic-minifier)[mmanos/laravel-casset

An asset management package for Laravel 4.

102.6k](/packages/mmanos-laravel-casset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
