Laravel 是拉维尔斯';DD助手功能是否正常工作?

Laravel 是拉维尔斯';DD助手功能是否正常工作?,laravel,laravel-5,laravel-5.1,Laravel,Laravel 5,Laravel 5.1,我喜欢使用dd函数进行调试。这一次,当我用它显示约会列表时,我看不到(没有可点击的箭头)属性和原始列表中的数据。我看到的是括号[…19],不知道为什么 Collection {#3061 ▼ #items: array:548 [▼ 0 => Appointment {#821 ▼ #table: "appointments" #fillable: array:16 [ …16] #connection: null #primar

我喜欢使用
dd
函数进行调试。这一次,当我用它显示约会列表时,我看不到(没有可点击的箭头)属性和原始列表中的数据。我看到的是括号
[…19]
,不知道为什么

Collection {#3061 ▼
  #items: array:548 [▼
    0 => Appointment {#821 ▼
      #table: "appointments"
      #fillable: array:16 [ …16]
      #connection: null
      #primaryKey: "id"
      #perPage: 15
      +incrementing: true
      +timestamps: true
      #attributes: array:19 [ …19]
      #original: array:19 [ …19]
      #relations: array:2 [ …2]
      #hidden: []
      #visible: []
      #appends: []
      #guarded: array:1 [ …1]
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      #morphClass: null
      +exists: true
      +wasRecentlyCreated: false
    }
    1 => Appointment {#822 ▶}
    2 => Appointment {#823 ▶}
    3 => Appointment {#824 ▶}
    4 => Appointment {#825 ▶}
    5 => Appointment {#826 ▶}
    6 => Appointment {#827 ▶}
    7 => Appointment {#828 ▶}
在列表的后面,我甚至看不到约会的内部(没有箭头):

但当我使用var_dump时,我的数据看起来很好:

    array(548) {
      [0]=>
      array(21) {
        ["id"]=>
        int(149)
        ["appointmenttype_id"]=>
        NULL
        ["appointmentlocationtype_id"]=>
        NULL
        ["appointment_start"]=>
        object(Carbon\Carbon)#812 (3) {
          ["date"]=>
          string(26) "2015-12-21 07:00:00.000000"
          ["timezone_type"]=>
          int(3)
          ["timezone"]=>
          string(16) "America/New_York"
        }
        ["appointment_end"]=>
        object(Carbon\Carbon)#811 (3) {
          ["date"]=>
          string(26) "2015-12-21 09:00:00.000000"
          ["timezone_type"]=>
          int(3)
          ["timezone"]=>
          string(16) "America/New_York"
        }

还有其他人经历过这种情况吗?

这是一个不太为人所知的警告,即返回太多的结果列表。通常,
dd()
是对返回的数据的快速概述,可以很好地“深入”处理较小的数据组。一旦你达到某个数字(我忘记了确切的数字,可能是500?),这个功能就不再有效了

如果在某个地方的代码中使用此数据之前您确实需要查看此数据,请在获取结果之前使用
limit()
子句,或者使用
dd($example[0])
查看单个结果的详细信息。希望有帮助

dd()

我相信有问题的一行是将
$maxDepth
设置为20,但我没有检查这个


查看Laravel
转储程序
,似乎无论如何都无法从Laravel内部覆盖此功能

我找到了一种解决这个问题的方法,虽然不推荐,但如果您真的想转储整个对象,请将以下代码段添加到/bootstrap/autoload.php

if (! function_exists('dd')) {
    /**
     * Dump the passed variables and end the script.
     *
     * @param  mixed
     * @return void
     */
    function dd()
    {
        array_map(function ($x) {
            $dumper = 'cli' === PHP_SAPI ? new \Symfony\Component\VarDumper\Dumper\CliDumper() : new \Illuminate\Support\Debug\HtmlDumper();
            $cloner = new \Symfony\Component\VarDumper\Cloner\VarCloner();
            $cloner->setMaxItems(-1);
            $cloner->setMaxString(-1);
            $dumper->dump($cloner->cloneVar($x));
       }, func_get_args());

        die(1);
    }
}
必须将其添加到行上方:

需要DIR'/../vendor/autoload.php'

它会覆盖laravel dd函数,并在转储之前在Symfony VarCloner对象上设置“setMaxItems”和“setMaxString”

if (! function_exists('dd')) {
    /**
     * Dump the passed variables and end the script.
     *
     * @param  mixed
     * @return void
     */
    function dd()
    {
        array_map(function ($x) {
            $dumper = 'cli' === PHP_SAPI ? new \Symfony\Component\VarDumper\Dumper\CliDumper() : new \Illuminate\Support\Debug\HtmlDumper();
            $cloner = new \Symfony\Component\VarDumper\Cloner\VarCloner();
            $cloner->setMaxItems(-1);
            $cloner->setMaxString(-1);
            $dumper->dump($cloner->cloneVar($x));
       }, func_get_args());

        die(1);
    }
}