In D8 I would like to display an array in the message part of a page. I did several things but could not get it work. What to do?

I installed the devel and kint modules.

I currently have changed in services.yml the settings into:

debug: true   
auto_reload: true   
cache: false

In the twig template I added

{{kint("I'm working from the page.html.twig")}}

This is displayed in the browser, so the current theme is displaying it which proves kint is working and the correct theme is used.

So now In my module file I have

$data_array = json_decode($data,true);
return $data_array;

The var_dump gives a lot of data in a array. However the kint is not displayed.

How to get the kint displayed this array?

  • Which module file do you have this in and in which function?
    – sonfd
    Commented May 6, 2018 at 12:41
  • In a custom module I'm building myself in a class file which is autoloaded.
    – Justme
    Commented May 6, 2018 at 14:25
  • 1
    1. Where in what file and function exactly are you calling kint()? 2. Better use ksm() as it prints the variables in the messages container which by default should be placed at the top of the content area.
    – leymannx
    Commented May 6, 2018 at 18:34

2 Answers 2


Try to take a look at this site it has a lot if useful information, print variables using kint.

They say that if you want to output in the message area then you shall use, ksm().

  • ksm is not displaying any info as well
    – Justme
    Commented May 6, 2018 at 8:45
  • Try to clear the cache.
    – user72672
    Commented May 6, 2018 at 8:57
  • nop, other suggestions?
    – Justme
    Commented May 6, 2018 at 15:53
  • 1
    Permissions error?
    – user72672
    Commented May 6, 2018 at 21:27

The solution is to run once before and to do the call different:


so below code is running good

$data_array = json_decode($data,true);
return $data_array;
  • This doesn't explain why kint() of devel/kint doesn't run, which is probably a permissions error as @Jdrupal commented in the other answer.
    – 4uk4
    Commented May 7, 2018 at 14:07
  • That could be but I cannot confirm it as the permission listed into drupal the king/ admin are correctly set in my configuration.
    – Justme
    Commented May 7, 2018 at 15:00
  • If you bypass permissions anyone can see the debug messages, don't forget to remove it then before going online ;-)
    – 4uk4
    Commented May 7, 2018 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.