PHPackages                             thecoderraman/laravel-assets-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. [Framework](/categories/framework)
4. /
5. thecoderraman/laravel-assets-version

ActiveLibrary[Framework](/categories/framework)

thecoderraman/laravel-assets-version
====================================

Laravel static assets versioning via query string: app.js → app.js?v=d41d8cd98f

v1.0(2y ago)075MITPHPPHP ^7.3|~8

Since Dec 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/TheCoderRaman/laravel-assets-version)[ Packagist](https://packagist.org/packages/thecoderraman/laravel-assets-version)[ Docs](https://github.com/TheCoderRaman/laravel-assets-version)[ RSS](/packages/thecoderraman-laravel-assets-version/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (3)Used By (0)

Assets Version
==============

[](#assets-version)

 [![license](https://camo.githubusercontent.com/74d02d1137311daafd9b7f0bc477464ff77a221cbf908ecc27caf96974be51b7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f546865436f64657252616d616e2f6c61726176656c2d6173736574732d76657273696f6e)](./LICENSE "license") [![laravel](https://camo.githubusercontent.com/99e7d7d2aab8e2a2488cd774c993527e418cd75da49b4557363b2b368c0993ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6f676f2d6c61726176656c2d626c75653f6c6f676f3d6c61726176656c)](https://laravel.com "laravel") [![Latest Version on Packagist](https://camo.githubusercontent.com/4098fb92549c9425c0ebda22773b858927ee23b41875e91fbab98d34ff68990b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f546865436f64657252616d616e2f6c61726176656c2d6173736574732d76657273696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/TheCoderRaman/laravel-assets-version "laravel")

 [![logo](./resources/logo.png?raw=true)](./resources/logo.png?raw=true)

   ![UyScuti](./resources/text-logo-light.png?raw=true)

🦸‍♂️ About
----------

[](#‍️-about)

By incorporating query strings, Laravel assets version facilitates static assets versioning, as exemplified by the transformation of app.js into app.js?d41d8cd98f. This method allows for efficient cache busting, ensuring that updated versions of static assets are promptly recognized and utilized by web browsers. Through the addition of unique query strings, such as the appended d41d8cd98f, the system effectively distinguishes between different versions of the same static asset, thereby enhancing performance and reliability within web development projects.

Empower your web development with Laravel's dynamic assets versioning, seamlessly integrating query strings to ensure efficient cache busting and swift recognition of updated versions.

##### 👊 "Efficient cache busting with Laravel's dynamic versioning."

[](#-efficient-cache-busting-with-laravels-dynamic-versioning)

Major Technologies
------------------

[](#major-technologies)

- laravel

Structure
---------

[](#structure)

```
├───config
├───resources
├───src
│   ├───Console
│   ├───Contracts
│   ├───Helpers
│   └───Support
│       └───Facades
└───tests
    ├───Concerns
    ├───Feature
    └───Unit
```

### 💫 Requirements

[](#-requirements)

- PHP &gt;= 7.3

⚜️ Features
-----------

[](#️-features)

- Supports multiple hash algorithms for generating asset file versions.
- Supports different filters for filtering asset files during asset version generation.
- Automatically assigns a version to asset URLs when using the `asset_path()` helper function..

Getting Started 🎉
-----------------

[](#getting-started-)

These instructions will get you a copy of the library up and running on your local machine for production and development purposes.

#### 👨‍💻 Production Environment

[](#‍-production-environment)

###### Install this package

[](#install-this-package)

```
$ composer require thecoderraman/laravel-assets-version
```

###### Publish the config file:

[](#publish-the-config-file)

```
$ php artisan vendor:publish --tag=assets-version
```

###### Update Configuration File as Needed

[](#update-configuration-file-as-needed)

```
edit: config/assets-version.php
```

###### Update Environment File as Needed

[](#update-environment-file-as-needed)

```
# Directory for assets
ASSET_PATH=assets
# Path to assets directory
ASSET_URL=http://localhost/assets
```

#### 🕹️ Library Basic Usage

[](#️-library-basic-usage)

##### You can get the versioned url of any asset file by using the `below` helper function:

[](#you-can-get-the-versioned-url-of-any-asset-file-by-using-the-below-helper-function)

###### Using Helper Functions

[](#using-helper-functions)

```
# For Type Js
js_path('app.js');  // "assets/js/app.js?3085ede8f2"

# For Type Css
css_path('app.css');  // "assets/css/app.css?3ede8f2085"

# For Other Types
asset_path('images/logo.png');  // "assets/images/logo.png?e8f203ed85"
```

###### For Using inside laravel blade template

[](#for-using-inside-laravel-blade-template)

```

```

###### Using Facades

[](#using-facades)

```
