简体   繁体   English

Symfony 4转储功能无法正常工作

[英]Symfony 4 dump function doesn't work properly

I'm developing some REST APIS and the dump function stopped working in my dev env, it doesn't show any information about anything or return the usual output 我正在开发一些REST APIS并且转储功能在我的dev env中停止工作,它没有显示任何有关任何信息或返回通常的输出

I tried to debug using the dump() function (from the /vendor/symfony/var-dumper/Resources/functions/dump.php file) and the \\Symfony\\Component\\VarDumper\\VarDumper::dump() function with the same results: it doesn't show anything or throw a php exception. 我尝试使用dump()函数(来自/vendor/symfony/var-dumper/Resources/functions/dump.php文件)和\\ Symfony \\ Component \\ VarDumper \\ VarDumper :: dump()函数进行调试结果:它没有显示任何内容或抛出php异常。

Also, i've tried both: use the regular debug commands (ie bin/console config:dump-reference ) and reinstall the debug-bundle 此外,我尝试了两种方法:使用常规调试命令(即bin / console config:dump-reference )并重新安装debug-bundle

In this example my program returns a notification: Array to string conversion 在这个例子中,我的程序返回一个通知: Array to string conversion

$foo = array("asdads", "czxcxzc");
dump($foo);

In this other example the response is null 在另一个示例中,响应为空

$foo = "bar";
dump($foo);

I just need the regular output for this function: is really useful to debug and see whats going on with my program 我只需要这个函数的常规输出:对调试非常有用,看看我的程序是怎么回事

I think that i've figure this out. 我想我已经弄明白了。

The problem was that i've added the __destruct() method on my main controller class (App\\Controller) 问题是我在主控制器类(App \\ Controller)上添加了__destruct()方法

App\\Controller 应用程序\\控制器

abstract class Controller implements ContainerAwareInterface
{

use ContainerAwareTrait;
use ControllerTrait;    
...
public function __destruct()
{
   //Some stuffs here
}

I dont know why, but this method avoids loading for some of these debug methods (maybe some other features, but not sure about it) 我不知道为什么,但这种方法避免加载一些这些调试方法(也许一些其他功能,但不确定)

The solution (for now) was moving this __destruct() method to my app main controller. 解决方案(现在)将此__destruct()方法移动到我的应用程序主控制器。 Now everything works like a charm 现在一切都像魅力一样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM