首页>开发手册>Symfony>Debug Configuration Reference (DebugBundle)
Symfony 手册目录展开/收起

Symfony 7.4 LTS

Debug Configuration Reference (DebugBundle)

本文目录展开

官方英文资料(未自动翻译);本文按官方对应版本整理,保留说明和代码。站内处理包括移除站点导航、还原代码格式及调整链接。

The DebugBundle integrates the VarDumper component in Symfony applications. All these options are configured under the debug key in your application configuration.

# displays the default config values defined by Symfony
$ php bin/console config:dump-reference debug

# displays the actual config values used by your application
$ php bin/console debug:config debug

# displays the config values used by your application and replaces the
# environment variables with their actual values
$ php bin/console debug:config --resolve-env debug

Note

When using XML, you must use the http://symfony.com/schema/dic/debug namespace and the related XSD schema is available at: https://symfony.com/schema/dic/debug/debug-1.0.xsd

dump_destination

type: string default: null

Configures the output destination of the dumps.

By default, dumps are shown in the WebDebugToolbar when returning HTML. Since this is not always possible (e.g. when working on a JSON API), you can have an alternate output destination for dumps. Typically, you would set this to php://stderr:

# config/packages/debug.yaml
debug:
    dump_destination: php://stderr
<!-- config/packages/debug.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/debug"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:debug="http://symfony.com/schema/dic/debug"
    xsi:schemaLocation="http://symfony.com/schema/dic/services
        https://symfony.com/schema/dic/services/services-1.0.xsd
        http://symfony.com/schema/dic/debug https://symfony.com/schema/dic/debug/debug-1.0.xsd">

    <debug:config dump-destination="php://stderr"/>
</container>
// config/packages/debug.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container): void {
    $container->extension('debug', [
        'dump_destination' => 'php://stderr',
    ]);
};

Configure it to "tcp://%env(VAR_DUMPER_SERVER)%" in order to use the ServerDumper feature.

max_items

type: integer default: 2500

This is the maximum number of items to dump. Setting this option to -1 disables the limit.

max_string_length

type: integer default: -1

This option configures the maximum string length before truncating the string. The default value (-1) means that strings are never truncated.

min_depth

type: integer default: 1

Configures the minimum tree depth until which all items are guaranteed to be cloned. After this depth is reached, only max_items items will be cloned. The default value is 1, which is consistent with older Symfony versions.

theme

type: string default: dark

Changes the color of the dump() output when rendered directly in templates. The value of this option can be dark or light.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
Version

来源与许可

Symfony documentation contributors。本资料采用 CC BY-SA 3.0;本页为官方资料的站内整理版本,并非框架官方网站。 许可说明

Symfony 官方文档 · 原文来源 · 打开在线代码运行