2017 © Pedro Peláez
 

library laravel-assetic

Assetic support for Laravel 4

image

slushie/laravel-assetic

Assetic support for Laravel 4

  • Friday, June 26, 2015
  • by slushie
  • Repository
  • 4 Watchers
  • 38 Stars
  • 9,769 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 11 Forks
  • 2 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Laravel-Assetic

Easily integrate Assetic with Laravel 4., (*1)

Total Downloads Latest Stable Version Latest Unstable Version License, (*2)

Key Features

  1. Easily maintain assets within groups.
  2. Instant single file compilation, concatenation, and minification.
  3. Apply multiple filters to each group.
  4. Automatically updates output files when their inputs have been changed.
  5. Pre-compile assets using artisan asset:warm.

Usage

Add to your composer.json:, (*3)

"require": {
    "laravel/framework": "4.0.*",
    "slushie/laravel-assetic": "dev-master",
    "lmammino/jsmin4assetic": "1.0.0",
    "leafo/lessphp": "0.4.0"
}

After running composer update, you need to add the service provider (and optionally, alias the Asset facade) in your app/config/app.php file:, (*4)

'providers' => array(
    ...
    'Slushie\LaravelAssetic\LaravelAsseticServiceProvider',
    ...
),

'aliases' => array(
    ...
    'Asset'           => 'Slushie\LaravelAssetic\Facades\AssetFacade',
    ...
),

Once your app's configuration has been updated, generate the package config:, (*5)

php artisan config:publish slushie/laravel-assetic

Now the laravel-assetic configuration file will be available at:, (*6)

app/config/packages/slushie/laravel-assetic/config.php

Finally, edit the configuration file file to define your assets. You can define multiple groups, each with different filters and assets., (*7)

Defining Filters

Filters are defined within the package configuration file., (*8)

'filters' => array(
    'css_min'       => 'Assetic\Filter\CssMinFilter',
    'css_import'    => 'Assetic\Filter\CssImportFilter',
    'css_rewrite'   => 'Assetic\Filter\CssRewriteFilter',
    'embed_css'     => 'Assetic\Filter\PhpCssEmbedFilter',
    'less_php'      => 'Assetic\Filter\LessphpFilter',
    'js_min'        => 'Assetic\Filter\JSMinFilter',
    'coffee_script' => 'Assetic\Filter\CoffeeScriptFilter',
    'yui_js' => function () {
        return new Assetic\Filter\Yui\JsCompressorFilter('yui-compressor.jar');
    },
),

Adding Assets to Groups

Each group defines assets and filters as inputs, and an output file that should be included in your view., (*9)

'groups' => array(
    'main_js' => array(
        'filters' => array(
            'js_min',
        ),
        'assets' => array(
            'jquery',                       // Named asset defined below
            'assets/js/common/search.js',   // Single file
            'assets/js/coolarize/*js',      // Folder inclusion
        ),
        'output' => 'scripts.js',           // Writable output relative to public_path()
    ),
),

Using Assets in Views

Once defined, your groups can then be accessed from within your views using the Asset facade. To link to the main_js group, you can use the Asset::url() method as follows:, (*10)

<script src="<?php echo Asset::url('main_js'); ?>"></script>

This will output the URL to the asset file (in this example, /scripts.js)., (*11)

When the page loaded, Assetic will generate the file, joining all files and running the defined filters., (*12)

You can also generate the asset output files via the artisan command:, (*13)

php artisan asset:warm

Of course, this can be performed as a composer post-install command to generate assets at deployment time., (*14)

More Information

More information can be acquired by reading through the source, which is fully documented, or you may feel free to raise issues at https://github.com/slushie/laravel-assetic/issues, (*15)

The Versions

26/06 2015

dev-master

9999999-dev

Assetic support for Laravel 4

  Sources   Download

The Requires

 

by Josh Leder

26/06 2015

dev-laravel-4

dev-laravel-4

Assetic support for Laravel 4

  Sources   Download

The Requires

 

by Josh Leder

26/06 2015

v1.2.0

1.2.0.0

Assetic support for Laravel 4

  Sources   Download

The Requires

 

by Josh Leder

04/02 2015

v1.1.0

1.1.0.0

Assetic support for Laravel 4

  Sources   Download

The Requires

 

by Josh Leder

21/04 2014

1.0.0

1.0.0.0

Assetic support for Laravel 4

  Sources   Download

The Requires

 

by Josh Leder