August 9th, 2019
Devel has been around since 2003. It has been downloaded over 3.5 million times, and it runs on more than two hundred thousand websites. Devel, being one of the most popular and invaluable tools for constructing and coding sites, contains developer and debugging utilities to help ensure more efficiency during the most common development tasks.
Cache clear Conﬁg editor Container Info Current route info Element Info
Entity Info Events Info Execute PHP Field Info PHPinfo()
Rebuild Menu Reinstall Modules Routes Info Run cron State editor
Theme registry View Session
The dprint_r function is a tool for peeking inside of a Drupal array to see what's there. It formats the array into a human-readable paragraph, rather than just displaying all the variables one after the other in an endless and mostly incomprehensible strand-like PHP's print_r() function would do. There are several ways to implement it, and all of them require the devel module to work.
Sometimes, depending on where your particular module falls in the core's own build process, you might be able to generate a fatal error by trying to call dprint_r() from inside your own module. Even if devel exists, it might not be fully rendered as a set of PHP functions yet. If this happens to you, move this code snippet inside one of your module's functions rather than leaving it naked at the top of your module, and the error will stop.
Controlling Placement On The Page
You can generate the printed array into a block, into a footer, or into a $messages box, like the "login successful" message that Drupal prints out automatically when a user logs in.
Devel is now directly integrated into the core Toolbar module. Visible links are configurable. When in vertical mode, the Toolbar shows links to all the available features.
Services, Routing & Events
Drupal 8 adds a lot of new concepts and structures that developers need to understand to build new modules. Devel now provides report pages for services, routing, events, and many more.
Manage Configuration & State
You can use Devel to inspect and edit both systems.
This feature is the same as in Drupal 7. Devel provides a block that allows a quick switch between users.
The Twig engine in core allows module developers to add new functions and ﬁlters to be used in templates (HTTP:// twig.sensiolabs.org/doc/2.x/advanced.html). Devel adds three new Twig functions for template developers:
devel_dump($var) devel_message($var) devel_breakpoint()
Prints a complex data structure in an attractive way, the same as PHP function kpr(). Without arguments, devel_dump will display the full Twig context.
Prints a complex data structure in an attractive way in the message area, the same as PHP function dpm(). Without arguments, devel_message displays the full Twig context.
Forces the PHP interpreter to stop the same way as setting a breakpoint in an IDE. Available variables are in $context array. Actually, it works only with xDebug.
Devel now provides a way to replace the tool used for formatting and displaying the variables inspected through the debug functions. Dumpers are implemented using the new plugin system in core. Some of these plugins require external libraries to be enabled. Those libraries have to be installed with Composer. Available Dumpers:
Doctrine debug (the default one) uses DoctrineCommonPersistenceProxyDebug class
Drupal variable uses DrupalComponentUtilityVariable class Symfony var-dumper uses
ChromePHP uses the ChromePhp debugging tool
FirePHP uses the FirePhp debugging tool
Kint (in a sub-module, needs to be enabled) uses DrupalkintPluginDevelDumperKint class
If the var-dumper module is present and enabled, the class used by the dumper became DrupalvardumperPluginDevelDumperVarDumper, which provides more integration with Drupal data structures. Class names become links to the relative class in IDE (if conﬁgured). User roles become links the role edit page.
Adding A Dumper
Dumpers are plugins; contrib modules can add new dumpers to the system. ExampleDumper.php has to be in the PluginDevelDumpernamespace. Every dumper needs to implement the DevelDumperInterface interface or extend the DevelDumperBase class.
The old Devel query logger and memory proﬁler has been removed in favor of a new sub-module: Webproﬁler
The report pages that Devel shows about services routing and so on lists all data available on a Drupal website. Webproﬁler instead collects data about the rendered page, so it is useful to measure performance data and to debug every single response. The available data collectors are:
Assets Blocks Cache Conﬁg Database Devel Events
Extensions Forms Http Mail PHP Conﬁg Performance Timing
Request Routing Services State Theme Timeline User
Integration With Xhprof
Webprofiler collects a high-level Drupal data structure. For example, if we need PHP function level data, we need a hierarchical proﬁler like XHProf (or Tideways for PHP > 7.x). The Drupal XHProf module adds a new data collector for Webproﬁler
As you can see from its extensive features, Devel is an invaluable tool for constructing and coding websites. It has developer and debugging utilities to help ensure more efficiency during the most common development tasks. If you are a website developer, you should consider using Devel for all of your Drupal site development.