smtgr14/twig-debugbar

一个Twig扩展,用于访问PHP Debug Bar的渲染函数。

1.1.0 2018-03-09 06:19 UTC

This package is not auto-updated.

Last update: 2024-09-27 18:44:56 UTC


README

这是一个简单的Twig扩展,为PHP Debug Bar提供渲染函数。此扩展加载StandardDebugBar,并为Twig提供dbg_message、dbg_renderHead和dbg_render等函数。

需求

安装

composer require smtgr14/twig-debugbar

示例

$twig = new Twig_Environment(new Twig_Loader_Filesystem('Views'));
$debugbarExtn = $debugbarExtn = new Dougfelton\TwigDebugBar\Extension('/Path'); // Relative assets path to your web directory e.g. /assets/debug/
$twig->addExtension($debugbarExtn);

$debugbar = $debugbarExtn->getDebugBar(); // Returns DebugBar for use with normal debugbar operations.
<html>
	<head>
		{{ dbg_renderHead() }}
	</head>
	<body>
        <!-- array dump -->
        {{ dbg_message(array)|raw }}
        <!-- labeled message -->
        {{ dbg_message('Something Wrong', 'error')|raw }}
		{{ dbg_render()|raw }}
	</body>
</html>

致谢

此扩展是Mark Arneman扩展(在此处找到)和Doug Felton所做的更改的微小更新(为了与Twig v2兼容)。我的工作很少,如果您觉得这个扩展很有用,那么功劳应归功于Mark和Doug。我添加的唯一功能是getDebugBar方法,以便返回对象,使工具栏不仅限于模板渲染和消息方法。
我的工作很少,如果您觉得这个扩展很有用,那么功劳应归功于Mark和Doug。我添加的唯一功能是getDebugBar方法,以便返回对象,使工具栏不仅限于模板渲染和消息方法。