Debugging During Development in Drupal 8
By Allie Jones
Debug your PHP code efficiently without Devel module’s dpm(Drupal Print Message). With Drupal 8’s adoption of Symfony and object-oriented architecture, we need to adjust how we debug our code. Up until now, many of us have been using the convenient dpm function for debugging and introspection. However, dpm cannot print protected properties or provide information about methods of an object.
This makes it difficult to debug objects and classes. It’s time to learn a new approach! We will look at alternative methods to solve this problem such as:
- Xdebug with PHPStorm configuration - http://xdebug.org
- Devel and the WebProfiler (D8+) Drupal module https://www.drupal.org/project/devel
- Using the continuous integration tool Probo CI to speed up the testing and approval process - http://probo.ci/
We will create a module, break it and use the above tools to debug, test and fix the code. Whether you are dipping your toes into object-oriented PHP or you're an advanced developer, everyone can benefit from debugging their code more efficiently.
Everyone's development environments are different. This is a compilation of notes I took when I was setting up machine to work the following tools:
- drupal console
- drupal 'debug' mode
Zivtech Rocks My Socks
demo site and module https://github.com/AllieRays/debugging-drupal-8