hyoa/twig-profiler-variables-bundle
Composer 安装命令:
composer require hyoa/twig-profiler-variables-bundle
包简介
Show variables send to twig when using render method
README 文档
README
Description
Allow to see variables send by a controller to the twig template. Variables that cannot be serialized are ignored (it's variable that contain closure)
Installation
The bundle is designed to work with Symfony 3.4 or 4.x. Older version are not supported.
Install the bundle via Composer:
composer require --dev hyoa/twig-profiler-variables-bundle dev-master
Enable the bundle in your kernel:
####Symfony 4.x
# config/packages/framework.yaml framework: ... templating: engines: ['profiler_variables']
// config/bundles.php <?php return [ ... Hyoa\TwigProfilerVariablesBundle\TwigProfilerVariablesBundle::class => ['dev' => true] ];
####Symfony 3.4.x
# app/config/config_dev.yml framework: ... templating: engines: ['profiler_variables']
// app/AppKernel.php <?php public function registerBundles() { ... if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { ... if ('dev' === $this->getEnvironment()) { ... $bundles[] = new \Hyoa\TwigProfilerVariablesBundle\TwigProfilerVariablesBundle(); } } return $bundles; }
Example
<?php 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'], ] ] ); } }
Tests
The only test is an integration that assert the profiler received correctly the variables from the controller.
You can run it the following way: vendor/bin/phpunit
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-28
