2017 © Pedro Peláez
 

symfony-bundle cache-bundle

Provides a httpcache warmup command for Symfony2

image

zenstruck/cache-bundle

Provides a httpcache warmup command for Symfony2

  • Monday, February 1, 2016
  • by kbond
  • Repository
  • 3 Watchers
  • 37 Stars
  • 2,943 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 13 Versions
  • 6 % Grown

The README.md

ZenstruckCacheBundle

Build Status Scrutinizer Code Quality Code Coverage StyleCI Latest Stable Version License, (*1)

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., (*2)

Installation

  1. Add to your composer.json:, (*3)

    $ composer require zenstruck/cache-bundle
    
  2. Register this bundle with Symfony2:, (*4)

    // 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., (*5)

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:, (*6)

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., (*7)

  • 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:, (*8)

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

  1. Create a class that implements Zenstruck\CacheBundle\Url\UrlProvider:, (*9)

    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());
        }
    }
    
  2. Register the class as a service tagged with zenstruck_cache.url_provider:, (*10)

    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:             []

The Versions

19/03 2014

1.x-dev

1.9999999.9999999.9999999-dev http://zenstruck.com/project/ZenstruckCacheBundle

Provides a httpcache warmup command for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching httpcache

19/03 2014

v1.2.2

1.2.2.0 http://zenstruck.com/project/ZenstruckCacheBundle

Provides a httpcache warmup command for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching httpcache

11/12 2013

v1.2.1

1.2.1.0 http://zenstruck.com/project/ZenstruckCacheBundle

Provides a httpcache warmup command for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching httpcache

21/06 2013

v1.2.0

1.2.0.0 http://zenstruck.com/project/ZenstruckCacheBundle

Provides a httpcache warmup command for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

cache caching httpcache

25/03 2013
01/03 2013
28/02 2013