PHP code example of eglobal / template-cache-bundle
1. Go to this page and download the library: Download eglobal/template-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/ */
eglobal / template-cache-bundle example snippets
public function registerBundles()
{
$bundles = [
// ...
new EGlobal\Bundle\TemplateCacheBundle\EGlobalTemplateCacheBundle(),
];
}
namespace Acme\FooBundle\Controller;
use EGlobal\Bundle\TemplateCacheBundle\Annotation\CacheableTemplate;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class MyController extends Controller
{
/**
* @Route(methods={"GET"}, path="/my/foo.html", name="my.template.foo", options={"expose"=true})
* @CacheableTemplate("AcmeFooBundle:Template:foo.html.twig")
*/
public function fooAction()
{
// Your controller logic
}
/**
* @Route(methods={"GET"}, path="/my/bar.svg", name="my.template.bar", options={"expose"=true})
* @CacheableTemplate("AcmeFooBundle:Template:bar.svg.twig")
*/
public function barAction()
{
// Your controller logic
}
}