Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Opening The Black Box

Opening The Black Box

Trying to tame a modern, fully-featured web application like Drupal can be an exercise in frustration.

Why are you printing that piece of content there?
Why am I seeing a negative integer instead of a string from this function?
What could a PDOException in my Watchdog log possibly mean?
In this session, we will be going over useful debugging tools and techniques that can help you start to see into the inner workings of all versions of Drupal, including the new kid on the block, Drupal 8. You will be better prepared to start building truly custom features into your projects and you’ll be able to remain calm when you get the ineveitable email that your site is showing the dreaded White Screen Of Death at 4:45pm on a Friday afternoon.

Presented at:
DrupalCamp CT 2016
Full Slidedeck with Speaker Notes:
https://github.com/milsyobtaf/prez/raw/primary/2016/DrupalCampCT/opening-the-black-box_notes.pdf

milsyobtaf

August 20, 2016
Tweet

More Decks by milsyobtaf

Other Decks in Technology

Transcript

  1. DrupalCamp CT 8/20/2016
    Opening
    The
    Black Box

    View Slide

  2. Howdy!
    Dustin Younse
    @milsyobtaf
    I’m an engineer at
    Four Kitchens

    View Slide

  3. DrupalCamp CT 2014
    DrupalCamp CT 2016 (morning)
    DrupalCamp CT 2016 (afternoon)
    I guess I’m an Ivy League
    assistant professor now?

    View Slide

  4. What Is The Black Box?

    View Slide

  5. • Non-technical education
    • Self taught web skills
    • Above average Googling abilities
    • Late nights staring at error messages
    A Familiar Story?

    View Slide

  6. Mental Model of Drupal

    View Slide

  7. Mental Model of Drupal

    View Slide

  8. Mental Model of Drupal

    View Slide

  9. Mental Model of Drupal

    View Slide

  10. Mental Model of Drupal

    View Slide

  11. Start At The Beginning

    View Slide

  12. Text Editors
    • “Text Editors”
    • Text Editors
    • IDEs

    View Slide

  13. • Text Edit (Mac)
    • Notepad (Windows)
    • Nano (Linux / Mac)
    “Text Editors”

    View Slide

  14. • Notepad++ (Windows)
    • vim (Mac / Linux)
    • Dreamweaver (Mac / Windows)
    • Sublime Text (Mac / Linux / Windows)
    • Atom (Mac / Linux / Windows)
    Text Editors

    View Slide

  15. • PHPStorm (Mac / Linux / Windows)
    • Eclipse (Mac / Linux / Windows)
    • Komodo (Mac / Linux / Windows)
    Integrated Development
    Environments

    View Slide

  16. Development Environments
    • On your server
    • On your machine
    • On your machine, but it acts like the server

    View Slide

  17. Development Environments
    • FTP Development
    • “Cowboy coding”
    • Local Environments
    • MAMP / LAMP / Vagrant
    • Next generation
    • Kalabox

    View Slide

  18. • FTP Development
    • “Cowboy coding”
    • No version control up front
    • Little debugging visibility
    • Log files (maybe), debug statements
    • Watchdog logs (maybe)
    FTP Development

    View Slide

  19. • print_r()
    • Raw dump of a variable or context, no formatting
    • print_r($node);

    • dsm()
    • Formatted dump of a variable or context
    • dsm($node);
    Debug Statements in Code

    View Slide

  20. • MAMP / Dev Desktop / Native LAMP
    • Code runs entirely locally
    • Added bonus of offline work, no internet required
    • print_r(), dsm(), but also more
    • xdebug
    Local Development

    View Slide

  21. • Kalabox with Pantheon / Acquia integration
    • Custom Vagrant boxes (DrupalVM)
    • print_r(), dsm(), xdebug
    • Very accurate performance profiling
    • XHProf
    Local Development:
    The Next Generation

    View Slide

  22. Something Is Broken!

    View Slide

  23. View Slide

  24. Relax.

    View Slide

  25. Remember Cobble’s Knot

    View Slide

  26. • Is something not showing up?
    • New content - is it published?
    • Old content - are permissions set properly?
    • Is something showing up that shouldn’t?
    • Raw HTML and Javascript in a WYSIWYG field?
    What’s Broken?

    View Slide

  27. • Log Files
    • You should learn how to find your log files 

    before you need your log files
    • multitail
    • Linux / Mac utility to easily view logs

    with more options than tail
    Work From The Bottom Up

    View Slide

  28. • Custom Module
    • Theme template.php
    • Theme Template
    Where Is It Broken?

    View Slide

  29. View Slide

  30. The Scientific Method

    View Slide

  31. • Change one thing at a time
    • Test that change
    • Repeat
    Finally, Debugging

    View Slide

  32. • Save your progress as you work
    • Recreate your Features
    • Makes rabbit holes manageable
    git Is Your Friend

    View Slide

  33. • Remove your debug statements
    • Ensure you only changed as much as you 

    needed to change
    • You only commit dsm(‘Butts’); to master once
    git diff Is Your Friend

    View Slide

  34. git blame Finds Your Enemies

    View Slide

  35. git blame Finds Your Enemies

    View Slide

  36. • Can help you track down who wrote 

    the offending code
    • This should not be a witch hunt
    • This should be a chance to find 

    context for the issue
    git blame Is Your Friend

    View Slide

  37. Make The Future Easier

    View Slide

  38. • watchdog() (D7)
    • \Drupal::logger() (D8)
    • syslog Module
    • http://loggly.com
    • https:/
    /www.elastic.co/blog/heya-elastic-stack-and-x-pack
    • Write a test!
    • Simpletest
    • Behat
    Proactive Debugging

    View Slide

  39. @milsyobtaf

    View Slide

  40. Thank you!
    All content in this presentation, except where noted otherwise, is Creative Commons
    Attribution-ShareAlike 3.0 licensed and copyright Four Kitchens, LLC.

    View Slide