6

I'm getting a feeling that Devel got pretty much useless with D8. When I try to dump most of the drupal objects I get only (Object) Namespace\Class output. No fields data is printed. print_r is able to print a lot of information but it's close to useless because it's output is virtually unreadable.

Is there a way to nicely print (dpm?) contents of objects in D8?

  • Not really - it's the same deal as this unfortunately, extensive use of __get() and __set() in the entity classes can indeed make Devel pretty useless. var_dump() with XDebug installed (and configured to be very verbose) works well for me – Clive Mar 10 '14 at 15:15
  • Please post your comment as an answer. It's not as pretty as dpm's krumo output but helped, so you deserve a credit :) – SiliconMind Mar 10 '14 at 15:38
10

dpm() does not print any protected properties and it also doesn't know about methods. That's especially bad for content entities but applies to most objects in 8.x now.

The issue referenced in the answer from Daniel Wehner adds Kint, which is already much better, as it will give you protected properties and methods.

However, for content entities, it still won't be that helpful as the values are all within ->values and ->fields and it's not trivial to understand how those work, especially with multiple languages.

That's why we're also working on better integration for content entities with Kint, so that it will display the fields and their values, see the screenshot in that issue.

Until then, you can also always use the following to debug what's inside a node or other content entity:

<?php
dpm($node->toArray());
dpm($node->getFieldDefinitions());
?>

At least the first one also works well with debug(), which has the advantage that it also works when running tests.

| improve this answer | |
  • Looking forward to your integration. Awesome work! – Daniel Wehner Mar 11 '14 at 8:24
3

https://drupal.org/node/2034919 will care about this.

It first bring in a new library which somehow will be extendable so that drupal's own logic can be supported.

| improve this answer | |
1

See what berdir wrote +

dsm(get_object_vars($entity));
dsm(get_class_methods($entity));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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