0% found this document useful (0 votes)
52 views

Essential Debugging PHP Debugging Techniques Tips Tricks

The document discusses various PHP debugging techniques. It begins by explaining why debugging is important to fix bugs. It then covers basic debugging methods like using echo and var_dump and introducing errors. The document recommends using a debugger for better debugging. It discusses features of debuggers like breakpoints, stack traces, and variable inspection. It covers popular PHP debuggers like Xdebug, Zend Debugger, and phpdbg. It also provides tips on setting up debuggers with IDEs, Docker, CLI, and browser extensions. Finally, it discusses remote debugging and debug mode for debugging requests.

Uploaded by

petr low
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Essential Debugging PHP Debugging Techniques Tips Tricks

The document discusses various PHP debugging techniques. It begins by explaining why debugging is important to fix bugs. It then covers basic debugging methods like using echo and var_dump and introducing errors. The document recommends using a debugger for better debugging. It discusses features of debuggers like breakpoints, stack traces, and variable inspection. It covers popular PHP debuggers like Xdebug, Zend Debugger, and phpdbg. It also provides tips on setting up debuggers with IDEs, Docker, CLI, and browser extensions. Finally, it discusses remote debugging and debug mode for debugging requests.

Uploaded by

petr low
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Essential Debugging

PHP Debugging techniques, tips & tricks

Kaloyan Raev
Zend / Rogue Wave
$ whoami
Zend Studio Team Lead

Eclipse Committer

Live in Sofia, Bulgaria

Skier
Why Debugging?

Because we make bugs

Because we want to fix them!


Debugging in PHP 101

echo $myvar;

var_dump ( $myvar );

die ( "Unexpected value in myvar: $myvar" );

error_reporting ( E_ALL );
Better Way?

Use a debugger!
Breakpoints

$left == 10
Stack Traces
Variables Overview
Fine Execution Control
Changes in Last Step
In-Editor Inspections

Shift + Ctrl + I
Watched Expressions
Multiple Sessions
PHP Debugger Engines

Xdebug

Zend Debugger

phpdbg
Xdebug Zend Debugger phpdbg

Built-in PHP ✅
DBGp binary own
Communication protocol
XML-based PHP-specific XML-based

Available in PHP 7 (as of today) ✅


IDE Support ✅ ✅
Remote Debugging ✅ ✅ ✅
Profiling ✅ ✅
The Easiest Way for Setting Up PHP with Debugger

Out of the box!

v8.5 provides both Xdebug and Zend Debugger


Docker Containers

tommylau/xdebug - Apache + PHP + Xdebug

Tutorial: Debugging PHP Web Apps in a Docker Container


Just CLI Scripts

Zend Studio bundles PHP binaries with Zend Debugger included


No IDEs Please
phpdbg is for you

Built-in PHP since 5.6


as SAPI module

CLI user interface


Do It Yourself Stack

Instructions for Zend Debugger

Instructions for Xdebug

Instructions for phpdbg


Browser Toolbars

1. Request broadcast port


Browser
IDE
Toolbar
2. Response with debug info

n
io
ss
1. 3.

se
R R
eq eq

on
bu
ue ue

si
s

de
stw t

s
se
n
ith

pe

ug
O
de

b
4.

de
bu
g

n
co

pe
o

O
ki

2.
e Xdebug
Debug
Engine Zend Debugger
Xdebug Toolbars
Chrome Opera

➢ Xdebug helper ➢ Xdebug


➢ Xdebug enabler ➢ Xdebug launcher

Firefox Safari

➢ The easiest Xdebug ➢ Xdebug Toggler


➢ easy Xdebug
Zend Debugger Toolbars
Chrome

➢ zDebug

Firefox

➢ Zend Firefox Toolbar

Internet Explorer

➢ Zend Internet Explorer Toolbar


Z-Ray
Z-Ray Live!
Remote Debugging
Intranet

Direct Internet Connection

Firewall / Proxy

➢ SSH Tunneling - works for both Xdebug and Zend Debugger


➢ Zend Debugger Tunneling - easier to setup, does not require Zend Server
Debug Mode

Every request to server triggers a new debug session in IDE

Useful for debugging requests from mobile apps

Available only for Zend Debugger in Zend Server


Thank you!

Rate this talk: https://joind.in/15612

Follow me: @kaloyanraev

You might also like