incenteev/ hashed-asset-bundle
为 symfony/asset 应用基于资产哈希的版本
v1.5.0
2024-01-16 13:28 UTC
Requires
- php: >=7.4
- symfony/asset: ^4.4.13 || ^5.3 || ^6.0 || ^7.0
- symfony/cache: ^4.4.13 || ^5.3 || ^6.0 || ^7.0
- symfony/config: ^4.4 || ^5.3 || ^6.0 || ^7.0
- symfony/dependency-injection: ^4.4.13 || ^5.3 || ^6.0 || ^7.0
- symfony/finder: ^4.4.13 || ^5.3 || ^6.0 || ^7.0
- symfony/framework-bundle: ^4.4.13 || ^5.3 || ^6.0 || ^7.0
- symfony/http-kernel: ^4.4.13 || ^5.3 || ^6.0 || ^7.0
Requires (Dev)
- jangregor/phpstan-prophecy: ^1.0
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^1.5
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-symfony: ^1.1
- phpunit/phpunit: ^9.5
- symfony/phpunit-bridge: ^5.3 || ^6.0 || ^7.0
README
HashedAssetBundle 提供了一种资产版本策略,它使用文件内容的哈希值作为资产版本。这允许为每个资产单独(自动)提升版本。
安装
使用 Composer 安装包
$ composer require incenteev/hashed-asset-bundle
使用方法
在内核中注册包
// app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Incenteev\HashedAssetBundle\IncenteevHashedAssetBundle(), ); } }
然后配置 FrameworkBundle 以使用新的版本策略
framework: assets: version_strategy: incenteev_hashed_asset.strategy
高级配置
默认配置应该满足常见需求,但如果需要,包暴露了一些配置设置
incenteev_hashed_asset: # Absolute path to the folder in which assets can be found # Note: in case you apply a base_path in your asset package, it is not # yet applied to the string received by the bundle web_root: '%kernel.project_dir%/web' # Format used to apply the version. This is equivalent to the # `framework > assets > version_format` of the static version strategy # of FrameworkBundle. version_format: '%%s?%%s'
许可
此包遵循 MIT 许可。
替代项目
如果您想在资产管道中通过重命名文件来应用缓存破坏(例如使用 webpack-encore 版本功能),请查看 Symfony 本身提供的 json_manifest
策略。
报告问题或功能请求
问题和功能请求在 Github 问题跟踪器 中跟踪。