37 lines
1.5 KiB
Markdown
37 lines
1.5 KiB
Markdown
|
---
|
||
|
title: Stepping back into debugging
|
||
|
date: 2024-04-30
|
||
|
permalink: archive/2024/04/30/stepping-back-into-debugging
|
||
|
tags:
|
||
|
- software-development
|
||
|
- php
|
||
|
cta: ~
|
||
|
snippet: |
|
||
|
This week, I've set up Xdebug on a new project to help with some complicated debugging.
|
||
|
---
|
||
|
|
||
|
In PHP, we have functions like `var_dump()`, `dump()` and `dd()` that are used to debug code and print output to the screen.
|
||
|
|
||
|
In Drupal, we have functions like `dpm()` and `kint()`, too.
|
||
|
|
||
|
These functions are great for simple debugging but sometimes I need more, which is when I reach for a step debugger - namely, Xdebug.
|
||
|
|
||
|
This is common when working in complex legacy code, where you need to be able to see a breakpoint and step through the code to see what path it takes and what the state is at each step.
|
||
|
|
||
|
## Enter Xdebug
|
||
|
|
||
|
Xdebug is a tool I use fairly often and something I have configured on an individual project basis.
|
||
|
|
||
|
This week, I spent some time adding it to a new project and ensured my notes and documentation still worked.
|
||
|
|
||
|
I use Docker and Docker Compose on Linux, so there are slight changes compared to running PHP natively, so I wanted to make sure it still works.
|
||
|
|
||
|
I've added my latest setup to my [Drupal Docker Example repository][repo] and plan to add it to my standard [Build Configs] setup for Drupal projects.
|
||
|
|
||
|
If you use Docker Compose on Linux, it may be useful for you.
|
||
|
|
||
|
If you haven't tried Xdebug before, I suggest giving it a try and see if improves your debugging.
|
||
|
|
||
|
[build configs]: {{site.url}}/build-configs
|
||
|
[repo]: https://github.com/opdavies/docker-example-drupal
|