zenstruck / cache-bundle
此包已被废弃且不再维护。没有推荐替代包。
为Symfony2提供httpcache预热命令
v3.0.0
2016-02-01 20:37 UTC
Requires
- php-http/client-implementation: ^1.0
- php-http/httplug: ^1.0
- php-http/message-factory: ^1.0
- symfony/console: ^2.5|^3.0
- symfony/framework-bundle: ^2.5|^3.0
Requires (Dev)
- guzzlehttp/psr7: ^1.0
- matthiasnoback/symfony-dependency-injection-test: ^0.7.4
- php-http/guzzle5-adapter: ^0.4@dev
- sllh/php-cs-fixer-styleci-bridge: ^1.4
- symfony/css-selector: ^2.5|^3.0
- symfony/dom-crawler: ^2.5|^3.0
Suggests
- dpn/xml-sitemap-bundle: Create a sitemap with Symfony
- guzzlehttp/psr7: To use and auto discover GuzzleMessageFactory
- php-http/guzzle5-adapter: To use and auto discover Guzzle5HttpAdapter
- php-http/guzzle6-adapter: To use and auto discover Guzzle6HttpAdapter
This package is auto-updated.
Last update: 2020-10-28 14:26:46 UTC
README
为Symfony2提供httpcache预热命令。该命令简单地在一个url列表上执行一个GET请求。必须注册一个或多个url提供者。此bundle需要一个php-http/httplug和php-http/message-factory的实现。
安装
-
添加到您的
composer.json
$ composer require zenstruck/cache-bundle
-
使用Symfony2注册此bundle
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Zenstruck\CacheBundle\ZenstruckCacheBundle(), ); // ... }
配置
必须配置一个 http_client
(实现 Http\Client\HttpClient
的类或服务)和一个 message_factory
(实现 Http\Message\MessageFactory
的类或服务)。
zenstruck_cache: http_client: Acme\MyHttpClient # or a service (acme.my_http_client) message_factory: Acme\MyMessageFactory # or a service (acme.my_message_factory)
HttpCache预热命令
用法
app/console zenstruck:http-cache:warmup
网站地图提供者
此bundle附带一个URL提供者,它会查看一个网站地图列表以检索URL列表。如果给定一个没有网站地图或网站地图索引的URL,提供者首先查找{url}/sitemap_index.xml
以找到一组网站地图文件。如果没有找到索引,则默认使用{url}/sitemap.xml
。
- 有关如何创建网站地图的信息,请参阅http://www.sitemaps.org/。
- 有关使用Symfony2创建网站地图的信息,请参阅DpnXmlSitemapBundle。
要启用网站地图提供者,请在您的 config.yml
中进行配置。
zenstruck_cache: sitemap_provider: sitemaps: - http://example.com/sitemap.xml # detects if sitemap or sitemap index and act accordingly - http://example.com/en/sitemap.xml # same as above - http://www.example.com # trys http://example.com/sitemap_index.xml and http://example.com/sitemap.xml
添加自定义URL提供者
-
创建一个实现
Zenstruck\CacheBundle\Url\UrlProvider
的类use Zenstruck\CacheBundle\Url\UrlProvider; namespace Acme; class MyUrlProvider implements UrlProvider { public function getUrls() { $urls = array(); // fetch from a datasource return $urls; } public function count() { return count($this->getUrls()); } }
-
将类注册为带有
zenstruck_cache.url_provider
标签的服务my_url_provider: class: Acme\MyUrlProvider tags: - { name: zenstruck_cache.url_provider }
完整默认配置
zenstruck_cache: # Either a class or a service that implements Http\Client\HttpClient. http_client: ~ # Required # Either a class or a service that implements Http\Message\MessageFactory. message_factory: ~ # Required sitemap_provider: enabled: false sitemaps: []