Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

The symfony 3/Flex bundle for PhpFastCache integrating a phpfastcache service, a twig cache tag and a powerfull cache profiler integrated to the symfony profile

License

Notifications You must be signed in to change notification settings

PHPSocialNetwork/phpfastcache-bundle

Repository files navigation

Symfony 3 PhpFastCache Bundle

👍 Step 1: Include phpFastCache Bundle in your project with composer:

composer require phpfastcache/phpfastcache-bundle

🚧 Step 2: Setup your config.yml to configure your cache(s) instance(s)

# PhpFastCache configuration
php_fast_cache:
    drivers:
        filecache:
            type: Files
            parameters:
                path: "%kernel.cache_dir%/phpfastcache/"
  • More examples in Docs/Example/app/config

🔧 Step 3: Setup your AppKernel.php by adding the phpFastCache Bundle

$bundles[] = new phpFastCache\Bundle\phpFastCacheBundle();
  • See the file Docs/Example/app/AppKernel.php for more information.

🚀 Step 4: Accelerate your app by making use of PhpFastCache service

public function indexAction(Request $request)
{
    $cache = $this->get('phpfastcache')->get('filecache');
    $item = $cache->getItem('myAppData');
    
    if (!$item->isHit() || $item->get() === null) {
        $item->set('Wy app has now superpowers !!')->expiresAfter(3600);//1 hour
        $cache->save($item);
    } 
     
    // replace this example code with whatever you need
    return $this->render('default/index.html.twig', [
        'myAppData' => $item->get(),
        'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
    ]);
}

💥 phpFastCache Bundle support

Found an issue or had an idea ? Come here here and let us know !

About

The symfony 3/Flex bundle for PhpFastCache integrating a phpfastcache service, a twig cache tag and a powerfull cache profiler integrated to the symfony profile

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published