[英]drupal 8, how debug a class?
I want to train myself to use Drupal 8 (Im from drupal 7 =) ). 我想训练自己使用Drupal 8(来自drupal 7的Im =)。 So, I learned some symfony2 basics. 因此,我学习了一些symfony2基础知识。 Now, I would like know if there is a good way about the code debugging, I mean : Before with Drupal 7, I used the devel module for show the content of data (very usefull !). 现在,我想知道代码调试是否有好的方法,我的意思是:在使用Drupal 7之前,我使用devel模块显示数据的内容(非常有用!)。 I try this module for drupal 8 but the dpm function seems not work in the class context. 我为drupal 8尝试了此模块,但是dpm函数在类上下文中似乎不起作用。
Bu example, I use this code for alter some route : 例如,我使用此代码更改某些路线:
<?php
namespace...
use...
...
class RouteSubscriber extends RouteSubscriberBase{
public function alterRoutes(RouteCollection $collection){
// What is the best way for display the $collection array ? like a dpm ?
dpm($collection); // doen't work, nothing appears in any page
}
Thanks =) 谢谢=)
Use debug()
in Drupal 8. debug()
will print the content of the variables as messages on the site. 在Drupal 8中使用debug()
。 debug()
将变量的内容作为消息打印在站点上。 Alternatively, you can use a debugging tool like xdebug to examine your variables. 或者,您可以使用xdebug之类的调试工具来检查变量。
If you're used to using the Devel debug functions like dsm()
and dpm()
, you would feel right at home using Devel Kint . 如果您习惯使用dsm()
和dpm()
类的Devel调试功能,那么使用Devel Kint会让您感到宾至如归。 Just enable the module Devel Kint and use it in modules or theme with kint($variables)
. 只需启用Devel Kint模块,然后在带有kint($variables)
模块或主题中使用它kint($variables)
。
I would also look into using Xdebug and setting break points to debug at a deeper level. 我还将研究使用Xdebug并设置断点来进行更深层次的调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.