2017 © Pedro Peláez
 

library laravel-asset-version

The Laravel Assets Versioning Package

image

tooleks/laravel-asset-version

The Laravel Assets Versioning Package

  • Wednesday, February 8, 2017
  • by tooleks
  • Repository
  • 1 Watchers
  • 4 Stars
  • 2,542 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 25 % Grown

The README.md

The Laravel 5 Assets Versioning Package

This package performs versioning of the asset URL resources., (*1)

Asset link before versioning:, (*2)

https://website.domain/path/to/asset.css

Asset link after versioning:, (*3)

https://website.domain/path/to/asset.css?v=0.0.1

Requirements

PHP >= 7.0, Laravel >= 5.0., (*4)

Installation

Package Installation

Execute the following command to get the latest version of the package:, (*5)

composer require tooleks/laravel-asset-version

App Configuration

Service Registration

To register the service simply add Tooleks\LaravelAssetVersion\Providers\AssetServiceProvider::class into your config/app.php to the end of the providers array:, (*6)

'providers' => [
    ...
    Tooleks\LaravelAssetVersion\Providers\AssetServiceProvider::class,
],

If you prefer to use the service via facade interface add 'Asset' => Tooleks\LaravelAssetVersion\Facades\Asset::class into your config/app.php to the end of the aliases array:, (*7)

'aliases' => [
    ...
    'Asset' => Tooleks\LaravelAssetVersion\Facades\Asset::class,
],

Publishing File Resources

Run following command in the terminal to publish the package file resources:, (*8)

php artisan vendor:publish --provider="Tooleks\LaravelAssetVersion\Providers\AssetServiceProvider" --tag="config"

Configure Assets Version

Configure assets version number in the config/assets.php:, (*9)

...
'version' => '0.0.1',
...

Basic Usage Examples

Via Service Object

use Tooleks\LaravelAssetVersion\Contracts\AssetServiceContract;

$assetUrl = app(AssetServiceContract::class)->get('path/to/asset.css'); // 'http://website.domain/path/to/asset.css?v=0.0.1'

$secureAssetUrl = app(AssetServiceContract::class)->get('path/to/asset.css', true); // 'https://website.domain/path/to/asset.css?v=0.0.1'

Note: Secure option will be detected automatically if no second argument will be passed into the function and secure option configured to null in the config/assets.php:, (*10)

...
'secure' => null,
...

Via Service Facade Class

use Tooleks\LaravelAssetVersion\Facades\Asset;

$assetUrl = Asset::get('path/to/asset.css'); // 'http://website.domain/path/to/asset.css?v=0.0.1'

$secureAssetUrl = Asset::get('path/to/asset.css', true); // 'https://website.domain/path/to/asset.css?v=0.0.1'

Note: Secure option will be detected automatically if no second argument will be passed into the function and secure option configured to null in the config/assets.php:, (*11)

...
'secure' => null,
...

In The Layout (Blade Template)

<link href="{{ Asset::get('path/to/asset.css') }}" rel="stylesheet" type="text/css">

In The Layout (PHP Template)

<link href="<?= Asset::get('path/to/asset.css') ?>" rel="stylesheet" type="text/css">

The Versions

08/02 2017

dev-dev

dev-dev https://github.com/tooleks/laravel-asset-version

The Laravel Assets Versioning Package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oleksandr Tolochko

laravel css cache php assets js versioning

28/10 2016

dev-master

9999999-dev https://github.com/tooleks/laravel-asset-version

The Laravel Assets Versioning Package

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Oleksandr Tolochko

laravel css cache php assets js versioning

28/10 2016

1.0.2

1.0.2.0 https://github.com/tooleks/laravel-asset-version

The Laravel Assets Versioning Package

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Oleksandr Tolochko

laravel css cache php assets js versioning

26/10 2016

1.0.1

1.0.1.0 https://github.com/tooleks/laravel-asset-version

The Laravel Assets Versioning Package

  Sources   Download

MIT

The Requires

  • php ~7.0

 

by Oleksandr Tolochko

laravel css cache php assets js versioning

09/07 2016

1.0.0

1.0.0.0 https://github.com/tooleks/laravel-asset-version

The Laravel Assets Versioning Package

  Sources   Download

MIT

The Requires

  • php ~7.0

 

by Oleksandr Tolochko

laravel css cache php assets js versioning