BadCamp 2015
Debug Drupal with Devel, XDEBUG + More
About Us
Kalamuna makes the Internet for for mission-driven organizations driven to tinker, critique, and change the way things are. We specialize in design, strategy, user experience, and development.
John Ouellet
Sr. Developer & Support Manager
I dejank the jankness in your janky websites.
labboy0276
I am totes qualified, for realz
I have 99 DEBUG commands, and Drupal uses all of them.
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
display_errors = On
log_errors = On
ddebug_backtrace();
dpm();
drupal_set_message();
dd();
db_queryd();
TOO MANY CHOICES CAN MAKE YOU GO CRAZY!!!!
ini_set('display_startup_errors', TRUE);
views_trace();
dvm();
kpr();
dargs();
BUT John, which ones do I use??
Good Question
Quick Stuff on Debugging
Front End (HTML / CSS)
Use Google Chrome DevTools (f12 to open)
Front End (JS)
console.log() or alert() in code
Chrome DevTools - Sources Panel w/ Breakpoints
Quick Stuff on Debugging
WSOD
Put this in at the top of your index.php�
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
Quick Stuff on Debugging
Google your errors:
Copy and paste the error and edit it to just have the file name with line errors.
Notice: Trying to get property of non-object in metatag_views_post_render() (line 2116 of metatag.module).
Other great places to search are:
Drupal Answers - http://drupal.stackexchange.com/
Drupal.org - http://www.drupal.org
Drupal API - http://api.drupal.org/api/drupal
RTFM
Debug with DEVEL
Devel Module - https://www.drupal.org/project/devel
Devel Kint Module - https://www.drupal.org/project/devel
- Need Kint for Devel to work in Drupal 8.
Search Krumo - https://www.drupal.org/project/search_krumo
- Only for Drupal 7 right now.
All you really need is dpm();
Debug with DEVEL
If you don’t care what I have to say, then here is the list
of all the devel functions:
Show the people!
XDEBUG
BENEFITS
XDEBUG - INSTALL
XDEBUG - INSTALL
VAGRANT / LAMP / LEMP
sudo apt-get install php5-xdebug
XDEBUG - INSTALL
Add to your php.ini / xdebug.ini
zend_extension="/wherever/you/put/it/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
XDEBUG - INSTALL
Drupal 8 - add to your php.ini
xdebug.max_nesting_level = 256
xdebug.show_exception_trace = 0
xdebug.collect_params = 0
XDEBUG - INSTALL
Or Just Use Kalabox 2
Currently in alpha4 CLI.
GUI coming in a few months.
Comes with everything installed!
XDEBUG - SETUP
XDEBUG - SETUP (SUBLIME PROJECT - VAGRANT)
Create a folder called ~/sublime-projects
Create a file called yoursite.project
Next slide has config
XDEBUG - SETUP (SUBLIME PROJECT - KALABOX 2)
XDEBUG - SUBLIME COMMANDS + ADVICE
XDEBUG - SUBLIME COMMANDS + ADVICE
YOU ARE READY TO XDEBUG
Show the people!
Misc Debugging Tips with Watchdog
Watchdog
watchdog($variable);
watchdog('MY_DEBUG', 'message: %msg', array('%msg' => $variable), WATCHDOG_NOTICE);
watchdog(‘MY_DEBUG', '<pre>' . print_r($variable, TRUE). '</pre>');
D8 Version
\Drupal::logger('MY_DEBUG')->notice($variable);
www.kalamuna.com
john@kalamuna.com
Thank You!