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.

Overcoming crappy code

Building a Ruby CLI app

Docker and Kubernetes

Kerberoasting - From setup to cracking

Deploying Service or Ingress on GKE

Templating with GeoEngineer

Fowsniff — TryHackMe Writeup

Why Java is platform independent

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

Object Validator for PHP 8

How did we reduce Memcached memory usage in PHP at Wingie — Enuygun

Best practices for CodeIgniter API development — The Right Software

4 ways to inject dependencies in Symfony that you probably don’t know about?

Symfony Dependency Injection