How to debug like a pro using Xdebug, PHPStorm, and Docker.

What is XDebug?

Install and Configure Xdebug

pecl install xdebug; \
docker-php-ext-enable xdebug; \
echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.mode=develop,trace,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.start_with_request = yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.discover_client_host=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20200930/" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \

PHP 8.0.3 (cli) (built: Apr 10 2021 13:25:28) ( NTS )
Copyright © The PHP Group
Zend Engine v4.0.3, Copyright © Zend Technologies
with Xdebug v3.1.1, Copyright © 2002–2021, by Derick Rethans

Setup a server in PHPStorm

Configure Xdebug

Install Browser debugging extensions

Start Listening

Browser debugging extension
place a stopover
Debugger Tab




Software Developer @andela | Music Lover | Data Science Enthusiast.

Love podcasts or audiobooks? Learn on the go with our new app.

39 — A discussion with John Lunn

Internet controlled LED using Arduino and ESP8266 | Part 2

Build Oracle Graph on Docker (Part 1/2)

Setup Spark with IntelliJ IDEA on Linux Mint 20

Quicktime Playlist Windows

Quicktime Playlist Windows

How to Listen to YouTube with Screen OFF

A quick overview of the implementation of a fast spelling correction algorithm

The attitude of doing the last-minute change in production code kills the developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Olotin Temitope

Olotin Temitope

Software Developer @andela | Music Lover | Data Science Enthusiast.

More from Medium

Build Your Symfony Applications with ease using Ecotone

Scrub Up! Cleaning Your PHP Application With PHPStan

Write type-safe SQL with PHP

Intro To PSR (PHP standards recommendations)