PHP code example of hyoa / twig-profiler-variables-bundle

1. Go to this page and download the library: Download hyoa/twig-profiler-variables-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/ */

    

hyoa / twig-profiler-variables-bundle example snippets


// config/bundles.php


return [
    ...
    Hyoa\TwigProfilerVariablesBundle\TwigProfilerVariablesBundle::class => ['dev' => true]
];

// app/AppKernel.php


    public function registerBundles()
    {
        ...
        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
            ...
            if ('dev' === $this->getEnvironment()) {
                ...
                $bundles[] = new \Hyoa\TwigProfilerVariablesBundle\TwigProfilerVariablesBundle();
            }
        }

        return $bundles;
    }




namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class HomeController extends AbstractController
{
    /**
     * @Route("/")
     */
    public function indexAction()
    {
        return $this->render(
            'home.html.twig',
            [
                'page' => 'home',
                'users' => [
                   ['id' => 1, 'name' => 'toto'],
                   ['id' => 2, 'name' => 'tata'],
                ]
            ]
        );
    }
}