PHPackages                             eusonlito/laravel-packer - 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. eusonlito/laravel-packer

ActiveLibrary

eusonlito/laravel-packer
========================

A package for pack css and javascript files

v3.0.1(7mo ago)6218.4k↓22.2%14[1 PRs](https://github.com/eusonlito/laravel-Packer/pulls)1MITJavaScriptPHP &gt;=5.5CI failing

Since Aug 7Pushed 7mo ago7 watchersCompare

[ Source](https://github.com/eusonlito/laravel-Packer)[ Packagist](https://packagist.org/packages/eusonlito/laravel-packer)[ RSS](/packages/eusonlito-laravel-packer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (32)Used By (1)

Laravel &gt;= 5 Packer
======================

[](#laravel--5-packer)

[![Build Status](https://camo.githubusercontent.com/5ab09616afa8f3754370e01c8ece005fcca9f4c04ed820b0d3f05c8171bfdf49/68747470733a2f2f7472617669732d63692e6f72672f6575736f6e6c69746f2f6c61726176656c2d5061636b65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/eusonlito/laravel-Packer)[![Latest Stable Version](https://camo.githubusercontent.com/9c1396d4919a3c29c538e7e1ea8b451607662325b627b8a31a327b444f0f407c/68747470733a2f2f706f7365722e707567782e6f72672f6575736f6e6c69746f2f6c61726176656c2d7061636b65722f762f737461626c652e706e67)](https://packagist.org/packages/eusonlito/laravel-packer)[![Total Downloads](https://camo.githubusercontent.com/172d822d600c00a47376c67734d1296c2ee804c12ef17d3f73088b952022292b/68747470733a2f2f706f7365722e707567782e6f72672f6575736f6e6c69746f2f6c61726176656c2d7061636b65722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/eusonlito/laravel-packer)[![License](https://camo.githubusercontent.com/a64ee228e5d685e56e5b5a93d5b8be62e47c482fa9cb09deedc70b7eab2e30ed/68747470733a2f2f706f7365722e707567782e6f72672f6575736f6e6c69746f2f6c61726176656c2d7061636b65722f6c6963656e73652e706e67)](https://packagist.org/packages/eusonlito/laravel-packer)

Inspired by:

With this package you can pack and minify your existing css and javascript files. This process can be a little tough, this package simplies this process and automates it.

Also, you can resize/crop images to adapt thumbnails into your layouts.

If you want a Laravel &lt;= 4.2 compatible version, please use `v4.2` branch.

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

[](#installation)

Begin by installing this package through Composer.

```
{
    "require": {
        "eusonlito/laravel-packer": "master-dev"
    }
}
```

### Laravel installation

[](#laravel-installation)

```
// config/app.php

'providers' => [
    '...',
    'Eusonlito\LaravelPacker\PackerServiceProvider',
];

'aliases' => [
    '...',
    'Packer'    => 'Eusonlito\LaravelPacker\Facade',
];
```

Publish the config file:

```
php artisan vendor:publish --provider="Eusonlito\LaravelPacker\PackerServiceProvider"

```

Now you have a `Packer` facade available.

#### CSS

[](#css)

```
// resources/views/hello.blade.php

        // Pack a simple file
        {!! Packer::css('/css/main.css', '/storage/cache/css/main.css') !!}

        // Pack a simple file using cache_folder option as storage folder to packed file
        {!! Packer::css('/css/main.css', 'css/main.css') !!}

        // Packing multiple files
        {!! Packer::css(['/css/main.css', '/css/bootstrap.css'], '/storage/cache/css/styles.css') !!}

        // Packing multiple files using cache_folder option as storage folder to packed file
        {!! Packer::css(['/css/main.css', '/css/bootstrap.css'], 'css/styles.css') !!}

        // Packing multiple files with autonaming based
        {!! Packer::css(['/css/main.css', '/css/bootstrap.css'], '/storage/cache/css/') !!}

        // pack and combine all css files in given folder
        {!! Packer::cssDir('/css/', '/storage/cache/css/all.css') !!}

        // pack and combine all css files in given folder using cache_folder option as storage folder to packed file
        {!! Packer::cssDir('/css/', 'css/all.css') !!}

        // Packing multiple folders
        {!! Packer::cssDir(['/css/', '/theme/'], '/storage/cache/css/all.css') !!}

        // Packing multiple folders with recursive search
        {!! Packer::cssDir(['/css/', '/theme/'], '/storage/cache/css/all.css', true) !!}

        // Packing multiple folders with recursive search and autonaming
        {!! Packer::cssDir(['/css/', '/theme/'], '/storage/cache/css/', true) !!}

        // Packing multiple folders with recursive search and autonaming using cache_folder option as storage folder to packed file
        {!! Packer::cssDir(['/css/', '/theme/'], 'css/', true) !!}

```

CSS `url()` values will be converted to absolute path to avoid file references problems.

#### Javascript

[](#javascript)

```
// resources/views/hello.blade.php

    ...
        // Pack a simple file
        {!! Packer::js('/js/main.js', '/storage/cache/js/main.js') !!}

        // Pack a simple file using cache_folder option as storage folder to packed file
        {!! Packer::js('/js/main.js', 'js/main.js') !!}

        // Packing multiple files
        {!! Packer::js(['/js/main.js', '/js/bootstrap.js'], '/storage/cache/js/styles.js') !!}

        // Packing multiple files using cache_folder option as storage folder to packed file
        {!! Packer::js(['/js/main.js', '/js/bootstrap.js'], 'js/styles.js') !!}

        // Packing multiple files with autonaming based
        {!! Packer::js(['/js/main.js', '/js/bootstrap.js'], '/storage/cache/js/') !!}

        // pack and combine all js files in given folder
        {!! Packer::jsDir('/js/', '/storage/cache/js/all.js') !!}

        // pack and combine all js files in given folder using cache_folder option as storage folder to packed file
        {!! Packer::jsDir('/js/', 'js/all.js') !!}

        // Packing multiple folders
        {!! Packer::jsDir(['/js/', '/theme/'], '/storage/cache/js/all.js') !!}

        // Packing multiple folders with recursive search
        {!! Packer::jsDir(['/js/', '/theme/'], '/storage/cache/js/all.js', true) !!}

        // Packing multiple folders with recursive search and autonaming
        {!! Packer::jsDir(['/js/', '/theme/'], '/storage/cache/js/', true) !!}

        // Packing multiple folders with recursive search and autonaming using cache_folder option as storage folder to packed file
        {!! Packer::jsDir(['/js/', '/theme/'], 'js/', true) !!}

```

#### Images

[](#images)

All transform options availables at

```
// resources/views/hello.blade.php

    ...
        // Set width size to 500px using cache_folder default parameter (from settings)

        // Crop image to 200px square with custom cache folder (full path)

        // Crop image to 200px square center middle with custom cache folder (using cache_folder as base)

        // Crop image to 200px square center top with custom cache folder (using cache_folder as base)

```

### Config

[](#config)

```
return array(

    /*
    |--------------------------------------------------------------------------
    | Current environment
    |--------------------------------------------------------------------------
    |
    | Set the current server environment. Leave empty to laravel autodetect
    |
    */

    'environment' => '',

    /*
    |--------------------------------------------------------------------------
    | App environments to not pack
    |--------------------------------------------------------------------------
    |
    | These environments will not be minified and all individual files are
    | returned
    |
    */

    'ignore_environments' => ['local'],

    /*
    |--------------------------------------------------------------------------
    | Public accessible path
    |--------------------------------------------------------------------------
    |
    | Set absolute folder path to public view from web. If you are using
    | laravel, this value will be set with public_path() function
    |
    */

    'public_path' => realpath(getenv('DOCUMENT_ROOT')),

    /*
    |--------------------------------------------------------------------------
    | Asset absolute location
    |--------------------------------------------------------------------------
    |
    | Set absolute URL location to asset folder. Many times will be same as
    | public_path but using absolute URL. If you are using laravel, this value
    | will be set with asset() function
    |
    */

    'asset' => 'http://'.getenv('SERVER_NAME').'/',

    /*
    |--------------------------------------------------------------------------
    | Base folder to store packed files
    |--------------------------------------------------------------------------
    |
    | If you are using relative paths to second paramenter in css and js
    | commands, this files will be created with this folder as base.
    |
    | This folder in relative to 'public_path' value
    |
    */

    'cache_folder' => '/storage/cache/',

    /*
    |--------------------------------------------------------------------------
    | Check if some file to pack have a recent timestamp
    |--------------------------------------------------------------------------
    |
    | Compare current packed file with all files to pack. If exists one more
    | recent than packed file, will be packed again with a new autogenerated
    | name.
    |
    */

    'check_timestamps' => true,

    /*
    |--------------------------------------------------------------------------
    | Check if you want minify css files or only pack them together
    |--------------------------------------------------------------------------
    |
    | You can check this option if you want to join and minify all css files or
    | only join files
    |
    */

    'css_minify' => true,

    /*
    |--------------------------------------------------------------------------
    | Check if you want minify js files or only pack them together
    |--------------------------------------------------------------------------
    |
    | You can check this option if you want to join and minify all js files or
    | only join files
    |
    */

    'js_minify' => true,

    /*
    |--------------------------------------------------------------------------
    | Use fake images stored in src/images/ when original image does not exists
    |--------------------------------------------------------------------------
    |
    | You can use fake images in your developments to avoid not existing
    | original images problems. Fake images are stored in src/images/ and used
    | with a rand
    |
    */

    'images_fake' => true
);
```

If you set the `'check_timestamps'` option, a timestamp value will be added to final filename.

### Using Packer outside Laravel

[](#using-packer-outside-laravel)

```
require (__DIR__.'/vendor/autoload.php');

// Check default settings
$config = require (__DIR__.'/src/config/config.php');

$Packer = new Eusonlito\LaravelPacker\Packer($config);

echo $Packer->css([
    '/resources/css/styles-1.css',
    '/resources/css/styles-2.css'
], 'css/styles.css')->render();

echo $Packer->js('/resources/js/scripts.js', 'js/scripts.js')->render();

echo $Packer->js([
    '/resources/js/scripts-1.js',
    '/resources/js/scripts-2.js'
], 'js/')->render();
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance65

Regular maintenance activity

Popularity39

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 97% 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 ~140 days

Recently: every ~426 days

Total

30

Last Release

214d ago

Major Versions

v1.1.1 → v2.0.02015-05-18

v2.2.0 → v4.2.x-dev2020-01-25

v2.2.6 → v3.0.02023-03-02

PHP version history (2 changes)v1.0PHP &gt;=5.4

v2.1.0PHP &gt;=5.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/644551?v=4)[Lito](/maintainers/eusonlito)[@eusonlito](https://github.com/eusonlito)

---

Top Contributors

[![eusonlito](https://avatars.githubusercontent.com/u/644551?v=4)](https://github.com/eusonlito "eusonlito (98 commits)")[![ablunier](https://avatars.githubusercontent.com/u/4113587?v=4)](https://github.com/ablunier "ablunier (1 commits)")[![bradley-varol](https://avatars.githubusercontent.com/u/19194140?v=4)](https://github.com/bradley-varol "bradley-varol (1 commits)")[![sarfraznawaz2005](https://avatars.githubusercontent.com/u/201788?v=4)](https://github.com/sarfraznawaz2005 "sarfraznawaz2005 (1 commits)")

---

Tags

compressioncssjavascriptlaravelpackerlaravelminifypacker

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eusonlito-laravel-packer/health.svg)

```
[![Health](https://phpackages.com/badges/eusonlito-laravel-packer/health.svg)](https://phpackages.com/packages/eusonlito-laravel-packer)
```

###  Alternatives

[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[fitztrev/laravel-html-minify

Minifies the HTML output of Laravel 4 applications

414211.4k](/packages/fitztrev-laravel-html-minify)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k5.4k1](/packages/vinkius-labs-laravel-page-speed)[yocmen/html-minify

Minifies the HTML output of Laravel 5 applications (Originally from https://github.com/fitztrev/laravel-html-minify)

1713.7k](/packages/yocmen-html-minify)[ken/blade-minify

Laravel Blade Minify

128.9k1](/packages/ken-blade-minify)[bissolli/php-css-js-minifier

A PHP Class to merge and minify CSS and JavaScript files.

102.8k4](/packages/bissolli-php-css-js-minifier)

PHPackages © 2026

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