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

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

bpedroza/asset-compiler
=======================

An asset compiler for php. Compile multiple javascript or css files into a single file.

v1.1.0(8y ago)31.2k1MITPHPPHP &gt;=5.6.0

Since Sep 30Pushed 8y ago3 watchersCompare

[ Source](https://github.com/bpedroza/asset-compiler)[ Packagist](https://packagist.org/packages/bpedroza/asset-compiler)[ RSS](/packages/bpedroza-asset-compiler/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

Asset Compiler
==============

[](#asset-compiler)

This package will allow you to compile multiple assets into a single file and minify single or compiled assets. Currently supported types are css and javascript.

An additional benefit to this package is that is adds a cache buster.

Files are compiled, minified, and cache busted using the last modified time of the newest file. New files are not compiled every page load, only when a file changes in the compilation.

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

[](#installation)

Add `"bpedroza/asset-compiler": "1.1.*"` to your composer.json require array

Configuration
-------------

[](#configuration)

Start by creating a new instance of the `AssetCcompiler` and give it paths it needs to build your files. The constructor takes arguments for the absolute path to the assets and an http path. The http path can be relative or include the full web address.

```
$AssetCompiler = new \Bpedroza\AssetCompiler\AssetCompiler('/path/to/my/assets/', '/assets/');
```

OR

```
$AssetCompiler = new \Bpedroza\AssetCompiler\AssetCompiler('/path/to/my/assets/', 'http://www.example.com');
```

Next you can configure the paths to specific assets, debug, and exception behavior.

By default the css folder is assumed to be /css and the javascript folder is assumed to be /js

All configuration options are getters and setters and can be chained when setting. When the parameter is missing, it will return the current configuration value.

```
// As Setters
$AssetCompiler->config()
        ->cssPath('mycssfolder')
        ->jsPath('myjsfolder');

// As getter
$compiledFolderName = $AssetCompiler->config()->compiledFolder();
```

### Available configuration options

[](#available-configuration-options)

MethodDescriptionDefaultrootPathThe absolute path (set in constructor)`null`httpPathThe http path (set in constructor)`null`cssPathPath relative to root path where your css files live`'css'`jsPathPath relative to root path where your javascript files live`'js'`compiledFolderName of folder that will be created in both js and css folders for compiled files`'compiled'`debugWhen in debug, we won't compile or minify items to make it easier to debug.`false`ignoreMissingWhen true, we won't throw exceptions for missing files.`false`minifyWhen true, we will minify file contents.`true`Usage
-----

[](#usage)

Generate single, cache busted, files.

```
// Single css file
$AssetCompiler->getStyle('test1.css', ['attr1' => 'some value', 'type' => 'text/css']);

// Single js file
$AssetCompiler->getScript('test1.js', ['attr1' => 'some value', 'type' => 'text/javascript']);

// Compiled css file
$AssetCompiler->getStylesMulti(['test1.css', 'test2.css'], 'mycompiledcssfile.css', $attributes = []);

// Compiled javascript file
$AssetCompiler->getScriptsMulti(['test1.js', 'test2.js'], 'mycompiledjsfile.js', $attributes = []);
```

Output

```

```

Minified Output

```

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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

Total

3

Last Release

3167d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3336238?v=4)[Bryan](/maintainers/bpedroza)[@bpedroza](https://github.com/bpedroza)

---

Top Contributors

[![bpedroza](https://avatars.githubusercontent.com/u/3336238?v=4)](https://github.com/bpedroza "bpedroza (16 commits)")

---

Tags

assets-managementcssjavascriptminifyphplaravelloaderminifycompilerminificationasset

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[stolz/assets

An ultra-simple-to-use assets management library

289527.4k8](/packages/stolz-assets)[michalsn/minifier

Assets minification and versioning library for CodeIgniter 4.

5437.5k](/packages/michalsn-minifier)[fisharebest/laravel-assets

Asset management for Laravel

208.1k](/packages/fisharebest-laravel-assets)[grafite/forms

A remarkably magical form package for Laravel.

376.8k1](/packages/grafite-forms)[eusonlito/laravel-packer

A package for pack css and javascript files

6118.7k1](/packages/eusonlito-laravel-packer)

PHPackages © 2026

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