PHPackages                             gears/asset - 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. gears/asset

AbandonedArchivedRobo-tasks[Utility &amp; Helpers](/categories/utility)

gears/asset
===========

An Asset Minfication Pipeline for the Robo Task Runner.

v1.3.2(9y ago)4374[1 issues](https://github.com/phpgearbox/asset/issues)1MITJavaScriptPHP ^7.0

Since Nov 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/phpgearbox/asset)[ Packagist](https://packagist.org/packages/gears/asset)[ Docs](https://github.com/phpgearbox/asset)[ RSS](/packages/gears-asset/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (12)Versions (19)Used By (1)

> Looking for maintainers, I no longer do much if any PHP dev, I have moved on, mostly work in dotnet core, node.js &amp; golang these days. If anyone is keen to take over these projects, get in touch -

The Asset Gear
==============

[](#the-asset-gear)

[![Build Status](https://camo.githubusercontent.com/8cea7d07602331038c21db8eb8183a1175ff49af390ddbed35d3fa56f99dda29/68747470733a2f2f7472617669732d63692e6f72672f70687067656172626f782f61737365742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpgearbox/asset)[![Latest Stable Version](https://camo.githubusercontent.com/093445268dcdaec4d7ac3da337722186df49341cea2f4051827cd22303afd46c/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f61737365742f762f737461626c652e737667)](https://packagist.org/packages/gears/asset)[![Total Downloads](https://camo.githubusercontent.com/28b6752312d4c9f9164f8c858649177d26acbcbc5d7df0dd9b5291745387f540/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f61737365742f646f776e6c6f6164732e737667)](https://packagist.org/packages/gears/asset)[![License](https://camo.githubusercontent.com/f8a7fb20d9c568fa48a8bf83bd7b67ae6f5f88cf9d6363672babe0af2591b1d9/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f61737365742f6c6963656e73652e737667)](https://packagist.org/packages/gears/asset)[![Coverage Status](https://camo.githubusercontent.com/135dd729a193efde987d438da8bce6ae2173fba47ebb02b904b76caede05241a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70687067656172626f782f61737365742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/phpgearbox/asset?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/54a7522d4b55213e7d88d70ac72a765c4dc42fa0ea3aa54ece3a63bb135cb6ef/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70687067656172626f782f61737365742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpgearbox/asset/?branch=master)

**An Asset Minification Pipeline for the [Robo](http://robo.li/) Task Runner.**

How to Install
--------------

[](#how-to-install)

Installation via composer is easy:

```
composer require gears/asset

```

How to Use
----------

[](#how-to-use)

The first thing is that I make an assumption you know what the *Robo Task Runner* is and how the basics of it work. If this is not you, please head over to the robo website and familiarise yourself:

In your `RoboFile.php` you need to import the `Gears\Asset\loadTasks` trait like so:

```
class RoboFile extends Robo\Tasks
{
    use Gears\Asset\loadTasks;
}
```

### Asset Destination

[](#asset-destination)

The very first argument you must supply is the final destination of the asset you are building. This can either be a relative path to the current working directory or an absolute path.

```
$this->taskBuildAsset('/where/do/you/want/me');
```

### Asset Type

[](#asset-type)

The task is smart and will detect what sort of asset you are trying to build based on file extensions. It goes without saying that you **CAN NOT MIX**asset types in one build task.

For example this is invalid:

```
$this->taskBuildAsset('script.js')->source('styles.css')->run();
```

### Asset Source

[](#asset-source)

The task needs to know what source files will be used to build the final asset.
You can supply the source files in a number of ways.

- **Single Source File:**
    The simplest asset is one which has only one source file. All this would do is run `unbuilt.js` through the configured Js Minifier.

    ```
    $this->taskBuildAsset('built.js')->source('unbuilt.js')->run();
    ```
- **Single Source Folder:**
    Instead of a source file you can define a folder. The task will search for files in the folder that have the same extension as the destination file.

    ```
    $this->taskBuildAsset('built.css')->source('/my/styles')->run();
    ```

    > NOTE: Files inside folders are sorted by name. So you could manipulate the order that files are concatenated together by prefixing a numeric index to each source file.
- **Many Sources:**
    You can supply any array of source files and/or folders.

    ```
    $this->taskBuildAsset('built.js')->source
    ([
        '/js/jquery.js',
        '/js/jquery/plugins',
        '/js/main.js'
    ])->run();
    ```
- **Symfony Finder:**
    The last option is to supply your own configured Finder instance.

    ```
    $this->taskBuildAsset('built.js')
    ->source
    (
        (new Finder)
          ->files()
            ->in('/path/to/assets')
            ->name('*.js')
            ->sortByName()
    )
    ->run();
    ```

    > For documentation on the Finder refer to:

### Css Transpilation:

[](#css-transpilation)

The task supports transpiling both [Less](http://lesscss.org/)and [Scss](http://sass-lang.com/) to Css.

If are building a css asset, this happens automatically for you. Any of your source files that are detected with a `less` or `scss` file extension will be transpiled with either:

- [less.php](https://github.com/oyejorge/less.php)
- [scssphp](https://github.com/leafo/scssphp)

> NOTE: You can not supply a folder of less or scss files. If you did have a folder of such source files you could configure a Finder instance to find those files. Each file would be transpiled in isolation and then the output concatenated.

### Js Transpilation:

[](#js-transpilation)

To save any future questions, I don't believe there is any point in supporting say [TypeScript](http://www.typescriptlang.org/) or [Babel](https://babeljs.io/)simply because, to run both of those transpiliers you must have [node](https://nodejs.org) installed.

And if you have node, and you are programming in TypeScript or ES6 then chances are you will probably already be using some sort of js bundler.

**UPDATE 2017-03-16:**Came across an intresting project [v8js](https://github.com/phpv8/v8js). This could be used to run things like babel in a purely PHP environment. Checkout [php-babel-transpiler](https://github.com/talyssonoc/php-babel-transpiler).

However due to the installation barrier of the plugin (having to dick around with compilations of v8, etc) it seems like it would just be easier to use node.js directly.

Docker may provide a solution to the install problem but the projects that use this package (mostly wordpress sites) arn't running on docker yet and probably never will.

As much as I would like to turn this into the ultimate asset build pipeline for PHP in 2017, the fact is that it just makes more sense to use the tools that are designed for frontend builds directly instead of trying to shoehorn them into the PHP ecosystem.

Thus this package will remain as is and provide an older style, yet muture &amp; simple asset build pipeline. If a project called for anything fancy like ES6, TypeScript or React then there are other tools like [Browserify](http://browserify.org/), [Webpack](https://webpack.js.org/) &amp; [RollupJs](http://rollupjs.org/) that will do a much better job than anything built in PHP.

### Options

[](#options)

- **Debug:**
    By default the task will always minify your css or js asset. If you wish to only build the asset, which will just concatenate the source files. You can set debug to true like this:

    ```
    $this->taskBuildAsset(...)->source(...)->debug(true)->run();
    ```
- **Gz:**
    Optionally the task can create a gzipped version of the final asset. This is so that web servers can be configured to server the pre gzipped version of the file instead of gzipping the file on the fly.

    ```
    $this->taskBuildAsset(...)->source(...)->gz(true)->run();
    ```
- **AutoPrefix:**
    If building a css asset, the task will automatically run a css autoprefixer before outputting the file. Autoprefixing parses CSS and adds vendor prefixes to CSS rules using values from

    > For more info see:

    To turn this feature off:

    ```
    $this->taskBuildAsset(...)->source(...)->autoprefix(false)->run();
    ```
- **Template:**
    This is a cache busting feature. If you provide a valid file path to a HTML template. The task will then save the final asset with the current unix time-stamp between it's base name and it's extension.

    For example: `script.1456298250.js`

    It will then search and replace the template file for any references to the asset. The task is smart and uses a regular expression. So if your template contained the asset name without the time-stamp or it contained the asset name with a previously built time-stamp it will still update the reference.

    ```
    $this->taskBuildAsset(...)->source(...)->template('view.html')->run();
    ```

    > NOTE: The template does not have to strictly be a HTML file. It could be any text based file. So it will work just fine with view frameworks like Laravel Blade, Twig, Plates, Foil, etc.

---

Developed by Brad Jones -

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~47 days

Recently: every ~1 days

Total

19

Last Release

3391d ago

Major Versions

v0.4.1 → v1.0.02017-03-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2754772?v=4)[Brad Jones](/maintainers/brad-jones)[@brad-jones](https://github.com/brad-jones)

---

Top Contributors

[![brad-jones](https://avatars.githubusercontent.com/u/2754772?v=4)](https://github.com/brad-jones "brad-jones (17 commits)")

---

Tags

javascriptcssminificationrobostylesheets

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gears-asset/health.svg)

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k60.6M804](/packages/drush-drush)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)

PHPackages © 2026

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