parabol / parabol-cache-bundle
symfony3项目的自动Web缓存系统。
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2024-09-18 00:58:27 UTC
README
#ParabolCacheBundle ParabolCacheBundle为基于请求/响应事件的Symfony/Doctrine(目前只支持ORM)项目提供视图缓存功能。所有GET请求的响应(除了在bundle配置中定义为排除的动作外)都存储在symfony缓存目录中的独立和压缩的文件中。该bundle还会创建Doctrine查询的映射,以便自动清除与更改的实体相关的缓存文件。
优点
- 非常容易安装
- 只需3个简单安装步骤即可开始工作
- 自动为所有未排除的动作创建缓存
- 自动创建动作与实体之间的映射
- 在postPersist/postUpdate事件中自动清除与Doctrine实体相关的缓存文件。
- 压缩HTML输出 - 有助于获取Google PageSpeed Tools更好的结果 ;)
##它的工作原理...
安装
###1) 通过Composer安装
composer require parabol/parabol-cache-bundle
###2) 在app/AppKernel.php中通过在registerBundles()中添加来启用bundle
new Parabol\CacheBundle\ParabolCacheBundle()
###3) 通过添加到app/config/config.yml来更改默认的Doctrine EntityManager
parameters:
doctrine.orm.entity_manager.class: Parabol\CacheBundle\Doctrine\ORM\EntityManager
###祝贺,您的HTML缓存系统现在应该正在工作。
配置
###默认bundle配置
parabol_cache:
cache_dev: false
minifier_command:
minifier_command_params: -o :target :source --case-sensitive --collapse-boolean-attributes --collapse-inline-tag-whitespace --collapse-whitespace --html5 --keep-closing-slash --remove-attribute-quotes --remove-comments --remove-empty-attributes --use-short-doctype --minify-css --minify-js
exclude: []
exclude_pattern: ^\/(_|assetic|admin)
###启用html-minifier 在symfony config.yml文件中将minifier_command参数设置为html-minifier的路径,前面是node.js的路径
parabol_cache:
minifier_command: /usr/local/bin/node /usr/local/bin/html-minifier
或为了更好地移动项目,在parameters.yml中
parameters:
minifier_command: /usr/local/bin/node /usr/local/bin/html-minifier
您可以通过更改minifier_command_params来修改压缩后的输出,但请注意,值必须包括关键词::target和:source
###其他minifier
如果您想使用其他minifier,只需在minifier_command中放置正确的路径,并在minifier_command_params中放置适当的命令参数。
###从缓存中排除动作 要排除某些动作从缓存中,将它们的名称(Bundle:Controller:action)放入exclude数组中
parabol_cache:
exclude: [AppBundle:Default:index, AppBundle:Other:show]