<commit_before># Laravel >= 4.3 Packer

[![Build Status](https://travis-ci.org/eusonlito/laravel-Packer.svg?branch=master)](https://travis-ci.org/eusonlito/laravel-Packer)
[![Latest Stable Version](https://poser.pugx.org/laravel/packer/v/stable.png)](https://packagist.org/packages/laravel/packer)
[![Total Downloads](https://poser.pugx.org/laravel/packer/downloads.png)](https://packagist.org/packages/laravel/packer)
[![License](https://poser.pugx.org/laravel/packer/license.png)](https://packagist.org/packages/laravel/packer)

Inspired by: https://github.com/ceesvanegmond/minify

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 <= 4.2 compatible version, please use `v4.2` branch.

## Installation

Begin by installing this package through Composer.

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

### Laravel installation

```php

// config/app.php

'providers' => [
    '...',
    'Laravel\Packer\PackerServiceProvider',
];

'aliases' => [
    '...',
    'Packer'    => 'Laravel\Packer\Facades\Packer',
];
```

Publish the config file:

```
php artisan config:publish laravel/packer
```

Now you have a ```Packer``` facade available.

#### CSS

```php
// app/views/hello.blade.php

<html>
    <head>
        // Pack a simple file
        {{ Packer::css('/css/main.css', '/storage/cache/css/main.css') }}

        // Pack a simple file using base_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 base_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 base_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 base_folder option as storage folder to packed file
        {{ Packer::cssDir(['/css/', '/theme/'], 'css/', true) }}
    </head>
</html>
```

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

#### Javascript

```php
// app/views/hello.blade.php

<html>
    <body>
    ...
        // Pack a simple file
        {{ Packer::js('/js/main.js', '/storage/cache/js/main.js') }}

        // Pack a simple file using base_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 base_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 base_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 base_folder option as storage folder to packed file
        {{ Packer::jsDir(['/js/', '/theme/'], 'js/', true) }}
    </body>
</html>
```

#### Images
All transform options availables at https://github.com/oscarotero/imageCow

```php
// app/views/hello.blade.php

<html>
    <body>
    ...
        // Set width size to 500px
        <img src="{{ Packer::img('/images/picture.jpg', '/storage/cache/images/', 'resize,500') }}" />

        // Crop image to 200px square
        <img src="{{ Packer::img('/images/picture.jpg', '/storage/cache/images/', 'resizeCrop,200,200') }}" />

        // Crop image to 200px square center middle using base_folder parameter
        <img src="{{ Packer::img('/images/picture.jpg', 'images/', 'resizeCrop,200,200') }}" />

        // Crop image to 200px square center top using base_folder parameter
        <img src="{{ Packer::img('/images/picture.jpg', 'images/', 'resizeCrop,200,200,center,top') }}" /><commit_msg>Updated views routes<commit_after># Laravel >= 4.3 Packer

[![Build Status](https://travis-ci.org/eusonlito/laravel-Packer.svg?branch=master)](https://travis-ci.org/eusonlito/laravel-Packer)
[![Latest Stable Version](https://poser.pugx.org/laravel/packer/v/stable.png)](https://packagist.org/packages/laravel/packer)
[![Total Downloads](https://poser.pugx.org/laravel/packer/downloads.png)](https://packagist.org/packages/laravel/packer)
[![License](https://poser.pugx.org/laravel/packer/license.png)](https://packagist.org/packages/laravel/packer)

Inspired by: https://github.com/ceesvanegmond/minify

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 <= 4.2 compatible version, please use `v4.2` branch.

## Installation

Begin by installing this package through Composer.

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

### Laravel installation

```php

// config/app.php

'providers' => [
    '...',
    'Laravel\Packer\PackerServiceProvider',
];

'aliases' => [
    '...',
    'Packer'    => 'Laravel\Packer\Facades\Packer',
];
```

Publish the config file:

```
php artisan config:publish laravel/packer
```

Now you have a ```Packer``` facade available.

#### CSS

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

<html>
    <head>
        // Pack a simple file
        {{ Packer::css('/css/main.css', '/storage/cache/css/main.css') }}

        // Pack a simple file using base_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 base_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 base_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 base_folder option as storage folder to packed file
        {{ Packer::cssDir(['/css/', '/theme/'], 'css/', true) }}
    </head>
</html>
```

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

#### Javascript

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

<html>
    <body>
    ...
        // Pack a simple file
        {{ Packer::js('/js/main.js', '/storage/cache/js/main.js') }}

        // Pack a simple file using base_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 base_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 base_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 base_folder option as storage folder to packed file
        {{ Packer::jsDir(['/js/', '/theme/'], 'js/', true) }}
    </body>
</html>
```

#### Images
All transform options availables at https://github.com/oscarotero/imageCow

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

<html>
    <body>
    ...
        // Set width size to 500px
        <img src="{{ Packer::img('/images/picture.jpg', '/storage/cache/images/', 'resize,500') }}" />

        // Crop image to 200px square
        <img src="{{ Packer::img('/images/picture.jpg', '/storage/cache/images/', 'resizeCrop,200,200') }}" />

        // Crop image to 200px square center middle using base_folder parameter
        <img src="{{ Packer::img('/images/picture.jpg', 'images/', 'resizeCrop,200,200') }}" />

        // Crop image to 200px square center top using base_folder parameter
        <img src="{{ Packer::img('/images/picture.jpg', 'images/', 'resizeCrop,200,200,center,top') }}" />
{'fraction_non_alphanumeric': 0.1777153393625428, 'fraction_numerical': 0.006848713671086136, 'mean_word_length': 2.8913563375469766, 'pattern_counts': {'":': 4, '<': 33, '<?xml version=': 0, '>': 39, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1234091', 'n_tokens_mistral': 3661, 'n_tokens_neox': 3477, 'n_words': 910}