symfony/asset
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The Symfony/Asset is a useful PHP package that manages the URL generation and versioning of web assets. These web assets can include CSS stylesheets, JavaScript files, and image files. This package allows for improved control and management of your web assets, which can be essential for complex web projects or high-traffic websites.
To make use of the Symfony/Asset package in your projects, you would usually start by installing the package via Composer:
composer require symfony/asset
After having successfully installed Symfony/Asset, you may manage your web assets by following the guideline below:
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
$package = new Package(new StaticVersionStrategy('v1'));
// In your CSS file linking
echo $package->getUrl('/image.png'); // Outputs: /image.png?v1
In this example, a new Package is created with a static version strategy of 'v1'. When the getUrl() method is called, it appends the version 'v1' to the file URL. This is particularly helpful when you need to enforce browser cache busting when your static assets like css or js files change.
The Symfony/Asset documentation provides the detailed guide on how to utilize this package effectively. Click here to get a comprehensive overview of the Symfony Asset Component. The documentation provides examples, best practices and extensive explanation on managing web assets.