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,081
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,717
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.1k
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,398
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
10 votes

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

You can do the following to output array data to be viewed in watchdog: // Directly use values. watchdog("log_name", '<pre>' . print_r( $my_object, true) . '</pre>'); Then goto /admin/...
Patoshi パトシ's user avatar
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
  • 18k
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
  • 692
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.1k
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

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

You should pass the object into the $variables array, and then in one of the Twig templates issue {{ dump(var) }}. Drupal might be using output buffering there, which would explain why you don't see ...
Yam Marcovic's user avatar
6 votes
Accepted

Copy path to variable in array using Kint

It seemed there was no solution so I just copied the search_krumo module and changed it a bit so it works with Drupal 8 and kint and made search_kint. I've only just done the first push so isn't ...
Felix Eve's user avatar
  • 6,453
6 votes

How to debug or explore an unknown object or array too big for Drupal's debug()?

Devel Devel module provides dd() command which is very useful for dumping very large object. Just run dd($vars) in the middle of code, it'll dump any object to the temporary file in your Drupal temp ...
kenorb's user avatar
  • 14.2k
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.1k
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,476
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,081
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

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
  • 186
6 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
  • 18k
5 votes

dpm() does not display any results on screen

If you want to print it from inside a function without touching (or having) a template file, try this: $nid = 3; $node = node_load($nid); dpm($node); print theme('status_messages');
Gavin Mcdonough's user avatar
5 votes
Accepted

How to get a backtrace in Drupal, without problems like out-of-memory when huge objects are in the trace?

I find this useful as a less memory intensive Drupal-friendly way to backtrace PHP as a one-off code snippet to temporarily drop into a troublesome location without installing modules or server-side ...
user56reinstatemonica8's user avatar
5 votes

Drupal Settings for PHPStorm

Relevant for PHPStorm 10: Disable the Force break at the first line when a script is outside the project setting. This is accessible under Settings: Languages & Frameworks > PHP > Debug > ...
mradcliffe's user avatar
  • 5,917
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

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