PHP code example of epiphany / service-cache-bundle

1. Go to this page and download the library: Download epiphany/service-cache-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

epiphany / service-cache-bundle example snippets



use Epiphany\ServiceCacheBundle\Proxy\ProxyGenerator;

....

ProxyGenerator::registerNamespace($loader,__DIR__); 

return $loader;

class WeatherDataService
{
    /**
     * Get the weather forecast for a date and location
     *
     * @service-cache-enable
     *
     * @service-cache-key param date
     * @service-cache-key param location
     * @service-cache-key date Y-m-d-H
     *
     * @service-cache-option compressed y 
     * 
     * @service-cache-expires 0
     * 
     * @param  DateTime $date     
     * @param  string   $location 
     * @return array    forecast data
     */
    public function forecastForDate(\DateTime $date, $location) {

        //....

class EpiphanyServiceCacheBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        // this pass will override standard service classes with our generated proxy classes
        $container->addCompilerPass(new OverrideServiceCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
    }
}