zenstruck / cache-bundle
Provides a httpcache warmup command for Symfony2
Installs: 10 987
Dependents: 0
Suggesters: 0
Security: 0
Stars: 39
Watchers: 3
Forks: 2
Open Issues: 0
Type:symfony-bundle
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
Provides a httpcache warmup command for Symfony2. The command simply executes a GET
request on a list of urls.
One or more url providers must be registered. This bundle requires an implementation of
php-http/httplug and
php-http/message-factory.
Installation
-
Add to your
composer.json
:$ composer require zenstruck/cache-bundle
-
Register this bundle with Symfony2:
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Zenstruck\CacheBundle\ZenstruckCacheBundle(), ); // ... }
Configuration
An http_client
(class or service implementing Http\Client\HttpClient
) and message_factory
(class or service implementing Http\Message\MessageFactory
) must be configured.
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 Warmup Command
Usage:
app/console zenstruck:http-cache:warmup
Sitemap Provider
This bundle comes with a URL provider that looks at a list of sitemaps to retrieve a list of urls. If a url is
given without the sitemap or sitemap index, the provider first looks for a {url}/sitemap_index.xml
to find a
set of sitemap files. If no index is found, it defaults to using {url}/sitemap.xml
.
- See http://www.sitemaps.org/ for information on how to create a sitemap.
- See DpnXmlSitemapBundle for creating a sitemap with Symfony2.
To enable the sitemap provider, configure it in your 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
Add a Custom URL Provider
-
Create a class that implements
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()); } }
-
Register the class as a service tagged with
zenstruck_cache.url_provider
:my_url_provider: class: Acme\MyUrlProvider tags: - { name: zenstruck_cache.url_provider }
Full Default Config
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: []