I write tests for a custom module using Drupal\simpletest\WebTestBase. I can not find a method, how to debug the configuration object.

I tried e.g. the following commands:

$config = \Drupal::config('mymodule.settings');

debug($config); // AJAX-HTTP-Error
debug(get_object_vars($config)); // Empty array
debug($config->getRawData()); // Empty array
debug($config->getOriginal()); // Empty array
dump($config); // AJAX-HTTP-Error
var_dump($config); // Needs extremely long time
ksm($config); // Nothing is shown
kint($config); // Nothing is shown
dpm($config); // ServiceNotFoundException
dpm($config->toArray()); // AJAX-HTTP-Error
dsm(get_object_vars($config)); // ServiceNotFoundException
print_r($config); // Needs extremely long time

The debug() command works fine for arrays and strings (and is nice integrated in the test report).

 debug($var, 'Label');
  • What are you expecting to be able to see in the config object? Bear in mind the storage is probably lazy; it's not like there's an array in there somewhere with every single config key and value in it, values are likely to be loaded when requested
    – Clive
    Commented Apr 11, 2017 at 11:57
  • I would like to see an array with all available settings. Commented Apr 11, 2017 at 12:01

1 Answer 1


You can use Config::get(), for which:

If no key is specified, then the entire data array is returned.


  • Thanks. I have found, that also debug(\Drupal::config('mymodule.settings')->geRawDatat()); works. The problem is, that I receive from both an empty array. But it is some other problem. (When I use \Drupal::config('system.site'), then I receive correct array.) Commented Apr 11, 2017 at 12:26

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.