hyoa/twig-profiler-variables-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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'],
                ]
            ]
        );
    }
}

Profiler page example

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固