Skip to main content
17 votes
Accepted

In Drupal 7 how do you output array objects to be view able in watchdog error reports?

You can use watchdog but the message part should be translatable, so any variables should use placeholders defined in the variables array. Check out format_string to see how these should work. ...
featherbelly's user avatar
  • 1,101
17 votes

How do I enable developer/debugging mode?

An easy option, if you have access to Drupal Console, is to enable the development/debugging environment using drupal site:mode dev; when you are ready to change it back to production, use drupal site:...
4life's user avatar
  • 4,727
17 votes
Accepted

How to stop twig debug from breaking HTML when inside tags?

You can apply |render|striptags|trim twig filters: <a href="{{ fields.path.content|render|striptags|trim }}" class="menu-item">{{ fields.title.content }}<span data-background-image="{{ ...
Francesc Bassas i Bullich's user avatar
16 votes

What is easiest way to debug variables in nodes, views, blocks and page twig templates?

What is easiest way to debug variables in nodes,views,blocks and page template Welcome to Kint 101 Installing Using Kint with Devel 8.x-2.1, which comes with the Devel module. Using Kint with Devel 4....
No Sssweat's user avatar
  • 31.4k
13 votes

How do I enable developer/debugging mode?

Here is the variable with the different values : $config['system.logging']['error_level'] = 'all'; // hide|some|all|verbose These error levels are defined in the Drupal Core Bootstrap, here is the ...
Flo Develop's user avatar
13 votes
Accepted

dump() not working in Drupal 8 (blank page, debbugging is enabled)

I agree with the comment left for the question: It seems you have an out of memory issue. Check the error log for the server. I had the same problem with dump() and kint() in an implementation of ...
Oana Hulpoi's user avatar
  • 1,418
12 votes

Debug "Access Denied"

Install the devel module and then Web Profile module which is bundled with it. You will then see the Symfony web profiler bar below the browser screen. Click on a Request gear icon, and it will show ...
Alexei Rayu's user avatar
10 votes

How to show all template suggestions for a page without using Devel Themer?

You can put this in your settings.php $conf['theme_debug'] = true; This outputs html comments on your page which will help you with debugging how the theme suggestions are selected.
Mamadou's user avatar
  • 288
9 votes

How to make use of Devel debugging functions on large or complex objects

The first problem can temporarily get fixed by changing the max array/object levels Kint will go deep. Currently this still has to be done by changing one line of code in the module. Though there ...
leymannx's user avatar
  • 18.3k
8 votes

How do I print the SQL query of a view in front end?

While you could install webprofiler module, if you've already got a custom module, it might be quicker to do this: /** * Implements hook_views_post_execute(). */ function ...
Dalin's user avatar
  • 704
8 votes
Accepted

How to make use of Devel debugging functions on large or complex objects

When working with entities and fields, you want to see the values, not the objects. For an entity, use $entity->toArray(), for a field object, use $field->getValue(). You can transform that ...
Berdir's user avatar
  • 83.3k
8 votes
Accepted

Struggling to enable twig debugging

Since Drupal 10.1.0 Twig debugging seems to be actived/deactivated according some settings stored in the state table: Change record. This prevents that these settings can be accidentally committed. ...
leymannx's user avatar
  • 18.3k
7 votes

dump(), kint() & print_r() are not working in .theme file

Just include Kint debugger in your theme file: require_once('modules/devel/kint/kint/Kint.class.php'); and use Kint like so: Kint::dump( $_SERVER );
aLx13's user avatar
  • 219
7 votes

How do I print the SQL query of a view in front end?

You can enable on "Show the SQL query" and "Show other queries run during render during live preview" on "www.example.com/admin/structure/views/settings" Hope it will help you.
visabhishek's user avatar
  • 1,346
7 votes
Accepted

How can I log variables to a txt file?

The DevelDumperManagerInterface interface is implemented by DevelDumperManager. This class is in turn used as a service, 'devel.dumper'. One way to use this function would be the following: $ddumper = ...
Stefanos Petrakis's user avatar
7 votes
Accepted

How to use kpr() or dsm() when i am not logged in

You need to grant the Access developer information permission to the anonymous user role. Be sure to revoke it again before releasing the site, it's an easy way to leak sensitive information.
Clive's user avatar
  • 167k
6 votes
Accepted

How do I print the SQL query of a view in front end?

The Devel module includes the webprofiler module; you have to enable that to see the query log. Note that there's currently a bug in core in 8.1 that prevents it from being used.
Berdir's user avatar
  • 83.3k
6 votes
Accepted

Why some twig templates have no file name suggestions

You can use the theme hook given to create your own theme hook / template suggestions or see additional suggestions that are not showing up in Twig debug, this happens occasionally. (I wonder if this ...
Danny Englander's user avatar
6 votes
Accepted

Debug plugin discovery

Most of the time it is because the file is not picked up, there are a few common cases for that: Ensure that the filename matches the class name exactly, case sensitive. Without the extension of ...
benjy's user avatar
  • 1,496
6 votes
Accepted

{{ kint() }} leads to install.php

That will be caused by an overload on resources. kint() is very resource intensive. If you are calling kint in a views-view-files.html.twig template for example then it could get called multiple times ...
featherbelly's user avatar
  • 1,101
6 votes
Accepted

how can I debug theme.theme file in my theme using phpstorm?

Go to Preferences -> Editor -> File Types Scroll down the Recognized File Types list until you find PHP; select it In Registered Patterns add *.theme Save You can now set breakpoints in *.theme files....
Clive's user avatar
  • 167k
6 votes
Accepted

What is easiest way to debug variables in nodes, views, blocks and page twig templates?

What is easiest way to debug variables in nodes,views,blocks and page template. Straight from the documentation: Far and beyond the best way to deal with printing out variables is to use Xdebug. If ...
Clive's user avatar
  • 167k
6 votes

What is easiest way to debug variables in nodes, views, blocks and page twig templates?

You can use twig_tweak module. You can use {{ drupal_dump(var) }} or its alias {{ dd(var) }} to get a variable dump which works even if twig debug mode is disabled. Here is full list of ...
amjad1233's user avatar
  • 184
5 votes
Accepted

How to set kint() to be closed by default?

I know this is an old question, but I just figured this out and this question comes up first on google. The option is already there. What you need to do is click next to the plus sign (the text ...
DrupalMonster's user avatar
5 votes
Accepted

Can you debug a site with Drush?

That error is often caused by PHP files that generate output they should not. Generally it's caused by errors like having a closing ?> and then a blank line at the end of the file. It's possible that ...
acrosman's user avatar
  • 2,728
5 votes

Can't get drush script to stop at breakpoint with Xdebug/Phpstorm

I just had this problem. It happened because I was using drush launcher (https://github.com/drush-ops/drush-launcher). This tool allows to type "drush" in your Drupal directory, instead of "./vendor/...
Yann's user avatar
  • 51
5 votes
Accepted

Can kint be used to debug templates?

The object/array is too big for your server resources to handle the default kint settings. Edit modules/devel/kint/kint/config.default.php and set $_kintSettings['maxLevels'] to a lower number to ...
No Sssweat's user avatar
  • 31.4k
5 votes
Accepted

what when displaying a variable with kint crashes?

Usually D8 $variables contain way too much data, and browser struggle to render it for you. I strongly suggest to use xdebug or similar debugger, all modern IDEs support it. It makes developer's life ...
Artreaktor's user avatar
5 votes

Protect drupal code injection from url

The logged requests are clearly attacking the security vulnerability SA-CORE-2018-002. But this is not your main concern now when you've already been hacked, because most hackers close the ...
4uk4's user avatar
  • 101k
5 votes
Accepted

How to find module that is updating my node after insert

You could implement hook_module_implements_alter to list all modules that implement a specific hook this way: function myModule_module_implements_alter(&$implementations, $hook) { if ($hook === '...
MiharbKH's user avatar
  • 808

Only top scored, non community-wiki answers of a minimum length are eligible