2017 © Pedro Peláez
 

library asset

Asset Component for Orchestra Platform

image

orchestra/asset

Asset Component for Orchestra Platform

  • Tuesday, July 31, 2018
  • by crynobone
  • Repository
  • 3 Watchers
  • 44 Stars
  • 79,924 Installations
  • PHP
  • 8 Dependents
  • 5 Suggesters
  • 6 Forks
  • 1 Open issues
  • 27 Versions
  • 3 % Grown

The README.md

Asset Component for Orchestra Platform

Asset Component is a port of Laravel 3 Asset for Orchestra Platform. The component main functionality is to allow asset declaration to be handle dynamically and asset dependencies can be resolve directly from the container. It however is not intended to becoma an asset pipeline package for Laravel, for such purpose we would recommend to use Grunt or Gulp., (*1)

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

Table of Content

Version Compatibility

Laravel Asset
5.5.x 3.5.x
5.6.x 3.6.x
5.7.x 3.7.x
5.8.x 3.8.x
6.x 4.x
7.x 5.x
8.x 6.x

Installation

To install through composer, run the following command from terminal:, (*3)

composer require "orchestra/asset"

Configuration

Add following service providers in config/app.php., (*4)

'providers' => [

    // ...

    Orchestra\Asset\AssetServiceProvider::class,
    Collective\Html\HtmlServiceProvider::class,

],

Aliases

You might want to add Orchestra\Support\Facades\Asset to class aliases in config/app.php:, (*5)

'aliases' => [

    // ...

    'Asset' => Orchestra\Support\Facades\Asset::class,

],

Usage

Registering Assets

The Asset class provides a simple way to manage the CSS and JavaScript used by your application. To register an asset just call the add method on the Asset class:, (*6)

Registering an asset:

Asset::add('jquery', 'js/jquery.js');

The add method accepts three parameters. The first is the name of the asset, the second is the path to the asset relative to the public directory, and the third is a list of asset dependencies (more on that later). Notice that we did not tell the method if we were registering JavaScript or CSS. The add method will use the file extension to determine the type of file we are registering., (*7)

Dumping Assets

When you are ready to place the links to the registered assets on your view, you may use the styles or scripts methods:, (*8)

Dumping assets into a view:, (*9)

<head>
    {!! Asset::styles() !!}
    {!! Asset::scripts() !!}
</head>

Above code can also be simplified as:, (*10)

<head>
    {!! Asset::show() !!}
</head>

Asset Dependencies

Sometimes you may need to specify that an asset has dependencies. This means that the asset requires other assets to be declared in your view before it can be declared. Managing asset dependencies couldn't be easier in Laravel. Remember the "names" you gave to your assets? You can pass them as the third parameter to the add method to declare dependencies:, (*11)

Registering a bundle that has dependencies:, (*12)

Asset::add('jquery-ui', 'js/jquery-ui.js', 'jquery');

In this example, we are registering the jquery-ui asset, as well as specifying that it is dependent on the jquery asset. Now, when you place the asset links on your views, the jQuery asset will always be declared before the jQuery UI asset. Need to declare more than one dependency? No problem:, (*13)

Registering an asset that has multiple dependencies:, (*14)

Asset::add('jquery-ui', 'js/jquery-ui.js', ['first', 'second']);

Asset Containers

To increase response time, it is common to place JavaScript at the bottom of HTML documents. But, what if you also need to place some assets in the head of your document? No problem. The asset class provides a simple way to manage asset containers. Simply call the container method on the Asset class and mention the container name. Once you have a container instance, you are free to add any assets you wish to the container using the same syntax you are used to:, (*15)

Retrieving an instance of an asset container:, (*16)

Asset::container('footer')->add('example', 'js/example.js');

Dumping that assets from a given container:, (*17)

{!! Asset::container('footer')->scripts() !!}

Asset Versioning

Another option to increase response time is by utilizing browser caching, while there few ways to do this we pick last modified time as our way to version the Asset., (*18)

Asset::container()->addVersioning();

// or alternatively
Asset::addVersioning();

Note: this would only work with local asset., (*19)

You can remove adding versioning number by using:, (*20)

Asset::container()->removeVersioning();

// or alternatively
Asset::removeVersioning();

The Versions

31/07 2018
28/07 2018

3.6.x-dev

3.6.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

02/05 2018
18/04 2018

3.5.x-dev

3.5.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

18/02 2018
27/01 2017

3.4.x-dev

3.4.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

20/01 2017

v3.4.0

3.4.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

02/01 2017

3.3.x-dev

3.3.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

11/06 2016

v3.3.0

3.3.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

16/03 2016

3.2.x-dev

3.2.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

02/02 2016

3.1.x-dev

3.1.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

20/01 2016

v3.2.1

3.2.1.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

24/11 2015

v3.2.0

3.2.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

16/06 2015

v3.1.1

3.1.1.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

27/05 2015

3.0.x-dev

3.0.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

17/05 2015

v3.1.0

3.1.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

28/02 2015

2.2.x-dev

2.2.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform 2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

28/02 2015

2.1.x-dev

2.1.9999999.9999999-dev http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform 2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

05/02 2015

v3.0.0

3.0.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Asset Component for Orchestra Platform

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

08/05 2014

v2.2.0

2.2.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

04/03 2014

v2.1.1

2.1.1.0 http://orchestraplatform.com/docs/latest/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

18/12 2013

v2.1.0

2.1.0.0 http://orchestraplatform.com/docs/latest/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

09/12 2013

2.0.x-dev

2.0.9999999.9999999-dev http://orchestraplatform.com/docs/2.0/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

21/10 2013

v2.0.2

2.0.2.0 http://orchestraplatform.com/docs/2.0/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

19/07 2013

v2.0.1

2.0.1.0 http://orchestraplatform.com/docs/2.0/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform

19/06 2013

v2.0.0

2.0.0.0 http://orchestraplatform.com/docs/2.0/components/asset/

Orchestra Platform 2 Asset Component

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel asset orchestral orchestra-platform