Even You
Can Debug
WordCamp Birmingham 2014
Introduction
Hi, I'm Brian DiChiara, Freelance Web Developer
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
- 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
Setup Your Own:
staging1.domain.com
domain.staging.company.com
- WP Engine
- Site Ground
My Ideal Setup
1. Private Repo in BitBucket
2. Setup Locally, using AMPPS, XAMPP, MAMP Pro, or a custom *AMP setup.
3. FTPloy
- At minimum Dev, Staging, and Master Branch
- Ignore wp-config.php and wp-content/uploads
- Host file and VirtualHosts in Apache
- Local Database and DB String Replace
- SQLYog (Windows) or Sequel Pro (Mac)
- Match wp-config.php
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
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
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!
Rubber Ducks!
The End
Any Questions?
Other Resources
Mario Peshev (@no_fear_inc)
Mo Jangda (Toronto)
THank you!
briandichiara.com
@solepixel
Even You Can Debug
By Brian DiChiara
Even You Can Debug
My presentation from WordCamp to assist anyone in debugging WordPress websites.
- 9,060