2

After using the function kint() (in the submodule Devel Kint that is part of Devel) in my mytheme.theme file to output the variables :

function my_theme_preprocess_node(&$variables){
  kint($variables);
}

I get the following error:

RuntimeException: Failed to start the session because headers have already been sent by "C:\Drupal\modules\contrib\devel\kint\kint\Kint.class.php" at line 263. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 141 of vendor\symfony\http-foundation\Session\Storage\NativeSessionStorage.php).

My environment is as follows: Drupal 8.7.1, Devel modules:

 devel                       Devel                       Development         8.x-2.1 8002           Installed   no core
 devel_generate              Devel Generate              Development         8.x-2.1                Uninstalled no core
 kint                        Devel Kint                  Development         8.x-2.1 8000           Installed   no core

If anyone should know the cause of this (if it is down to the Devel module then where should I ask the question as the editor suggested that this forum is not the right place to ask about Drupal modules) - please help!

  • I've gotten this error many times, I think that it is because that kint is sending some headers that causes the page load to break. The error is only temporary and should disappear, when you remove the kint() call. – user72672 May 22 '19 at 13:04
  • 1
    Welcome to Drupal Answers! When you state facts and ask a question like Any suggestions? you are asking a too broad question. We cannot debug a site to which we don't have access. If then the PHP error is merely caused from Kint, this is not even a Drupal-related question, as Kint is a generic PHP tool, not a Drupal tool. – kiamlaluno May 22 '19 at 13:10
  • 1
    Is it the same when you call ksm($variables)? – leymannx May 22 '19 at 16:39
  • 1
    Thanks @leymannx, ksm($variables) works fine. Can I upvote your answer somehow? – Tommy May 22 '19 at 16:59
  • 1
    I always get this with kint(). ksm()works. I think it is a bug in Devel and should be posted as such to the project's issue queue. – Free Radical Jul 24 '19 at 5:32

Browse other questions tagged or ask your own question.