Even You
Can Debug
WordCamp Birmingham 2014
Introduction
Hi, I'm Brian DiChiara, Freelance Web Developer
http://briandichiara.com
@solepixel
What Is Debugging?
The process of
identifying
and
removing
errors
from computer software
What is the Problem?
It's not working.
I get an error.
It doesn't look right.
It's doing something funky.
Help me help you
What specifically is not working?
Can you please tell me the error message you are getting?
What are you expecting to happen?
What about it makes you think it's doing something funky?
Gather Data
Steps to Reproduce!
Browser/OS
supportdetails.com
Help > About
What is the URL?
Authentication Credentials (and test them!)
Screenshot
Print Screen / CMD+SHIFT+3 or 4
CloudApp
or
FluffyApp
/
Jing
Gist (gist.github.com)
File / Line Number
Locate the problem
DNS Issues
Who.is (
Chrome Extension
)
Check Name Servers
Verify A Records
Whoishostingthis.com
Browser Error Console (Chrome/Firefox/Safari)
F12 (Windows) or CMD+OPT+i (Mac)
Switch to another theme (Twenty Fourteen)
Disable Plugins
USE A STAGING SITE
Hosts
Database String Replace
Setup Your Own:
staging1.domain.com
domain.staging.company.com
WP Engine
Site Ground
My Ideal Setup
1. Private Repo in
BitBucket
At minimum Dev, Staging, and Master Branch
Ignore wp-config.php and wp-content/uploads
2. Setup Locally, using
AMPPS
,
XAMPP
,
MAMP Pro
, or a custom *AMP setup.
Host file and VirtualHosts in Apache
Local Database and
DB String Replace
SQLYog (Windows) or Sequel Pro (Mac)
Match wp-config.php
3.
FTPloy
Tools of the trade
Editors/IDEs
Sublime Text
(Mac/Windows/Linux)
PhpStorm
(Mac/Windows/Linux)
phpDesigner
(Windows)
Codebug
(Mac)
Coda 2
(Mac)
In-line Debugger
Debugging Resources
Plugins
Debug Bar
Plugin
Query Monitor
Plugin
Developer
Plugin
3rd Party Applications
Airbrake.io
Raygun.io
Xdebug
Nitty Gritty
Enable
WP_DEBUG
WP_DEBUG_LOG (true)
WP_DEBUG_DISPLAY (false)
Prefix ALL the things!
Use
function_exists()
,
class_exists()
,
defined()
, and
isset()
Avoid using @; use
try / catch
instead
OuTPUT Variables
debug_backtrace()
var_dump()
and
var_export()
global $wpdb;
$wpdb->request
console.log()
alert()
Last Resort
die('1');
Pink Sombrero
Disclaimer: Cowboy coding (or live site debugging)
is looked down upon and is the worst way
to debug a website.
$_SERVER['REMOTE_ADDR']
$_SERVER['HTTP_X_FORWARDED_FOR']
Check against your IP address!
what is my ip?
Rubber Ducks!
The End
Any Questions?
Other Resources
WordPress Codex
Mario Peshev (@no_fear_inc)
WordSesh
WP Realm Article
Mo Jangda (Toronto)
Debugging for WordPress Developers
THank you!
briandichiara.com
@solepixel
Made with Slides.com