PHPackages                             tooleks/laravel-asset-version - 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. [Caching](/categories/caching)
4. /
5. tooleks/laravel-asset-version

ActiveLibrary[Caching](/categories/caching)

tooleks/laravel-asset-version
=============================

The Laravel Assets Versioning Package

1.0.2(9y ago)745.7k↓59.3%3MITPHPPHP ~7.0

Since Jul 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/tooleks/laravel-asset-version)[ Packagist](https://packagist.org/packages/tooleks/laravel-asset-version)[ Docs](https://github.com/tooleks/laravel-asset-version)[ RSS](/packages/tooleks-laravel-asset-version/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

The Laravel 5 Assets Versioning Package
=======================================

[](#the-laravel-5-assets-versioning-package)

This package performs versioning of the asset URL resources.

Asset link before versioning:

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

```

Asset link after versioning:

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

```

Requirements
------------

[](#requirements)

PHP &gt;= 7.0, Laravel &gt;= 5.0.

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

[](#installation)

### Package Installation

[](#package-installation)

Execute the following command to get the latest version of the package:

```
composer require tooleks/laravel-asset-version
```

### App Configuration

[](#app-configuration)

#### Service Registration

[](#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:

```
'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:

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

#### Publishing File Resources

[](#publishing-file-resources)

Run following command in the terminal to publish the package file resources:

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

#### Configure Assets Version

[](#configure-assets-version)

Configure assets version number in the `config/assets.php`:

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

Basic Usage Examples
--------------------

[](#basic-usage-examples)

#### Via Service Object

[](#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`:

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

#### Via Service Facade Class

[](#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`:

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

#### In The Layout (Blade Template)

[](#in-the-layout-blade-template)

```

```

#### In The Layout (PHP Template)

[](#in-the-layout-php-template)

```
