Essential debugging php debugging techniques, tips & tricks

Post on 15-Feb-2017

813 views 6 download

Transcript of Essential debugging php debugging techniques, tips & tricks

Essential DebuggingPHP Debugging techniques, tips & tricks

Kaloyan RaevZend / Rogue Wave

$ whoamiZend 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 ✅

Communication protocol DBGpXML-based

binaryPHP-specific

ownXML-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 Pleasephpdbg is for you

Built-in PHP since 5.6 as SAPI module

CLI user interface

Browser Toolbars

Xdebug

Zend Debugger

Browser Toolbar

Debug Engine

IDE

1. Request with debug cookie

1. Request broadcast port

2. Ope

n deb

ug se

ssion

4. Ope

n deb

ug se

ssion

2. Response with debug info

3. Request

Z-Ray

Z-Ray Live!

Remote DebuggingIntranet

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