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.
- laravel
├───config
├───resources
├───src
│ ├───Console
│ ├───Contracts
│ ├───Helpers
│ └───Support
│ └───Facades
└───tests
├───Concerns
├───Feature
└───Unit- PHP >= 7.3
- 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..
These instructions will get you a copy of the library up and running on your local machine for production and development purposes.
$ composer require thecoderraman/laravel-assets-version$ php artisan vendor:publish --tag=assets-versionedit: config/assets-version.php# Directory for assets
ASSET_PATH=assets
# Path to assets directory
ASSET_URL=http://localhost/assets# 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"<link href="{{ asset_path('js/app.js') }}" rel="stylesheet"><?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use TheCoderRaman\AssetsVersion\Support\Facades\AssetsVersion;
class WelcomeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return string
*/
public function index()
{
// "assets/js/app.js?3085ede8f2"
dump(AssetsVersion::jsPath('app.js'));
// "assets/css/app.css?3ede8f2085"
dump(AssetsVersion::cssPath('app.css'));
// "assets/images/logo.png?e8f203ed85"
dump(AssetsVersion::assetPath('images/logo.png'));
}
}# For generating assets version cache file
$ php artisan assets-version:cache
# For removing assets version cached file
$ php artisan assets-version:clear$ git clone https://github.com/TheCoderRaman/laravel-assets-version.git
$ cd laravel-assets-version
$ composer install# Run Tests
$ composer run-script phpunit# Use TestBench
$ composer run-script testbench
$ composer run-script testbench:serve
$ composer run-script testbench:build
$ composer run-script testbench:prepare
$ composer run-script testbench:clear- master -> any pull request of changes this branch
- main -> don´t modify, this is what is running in production
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
- Fork the repo and create your branch:
#[type]/PR description - Ensure to describe your pull request:
Edit the PR title by adding a semantic prefix like
Added,Updated:,Fixed:etc. Title:#[issue] PR title -> #90 Fixed styles the button
In order to ensure that the Assets Version community is welcoming to all, please review and abide by the Code of Conduct.
If you discover a security vulnerability within Assets Version, please send an e-mail to Raman Verma via e-mail. All security vulnerabilities will be promptly addressed.
The Assets Version is open-sourced software licensed under the MIT License
