Debug Ghosts
December 26, 2025 · TFOL Dev Story · PHP, Twig, LAMPP Debugging
When debugging a PHP/Twig application, there are bugs—and then there are debug ghosts.
This is the story of a Twig template that kept printing code I had already deleted, a VS Code search that swore the code didn’t exist, and the subtle LAMPP configuration mistake that caused me to question reality.
If you’ve ever thought “I removed that line—why is it still running?”, this story is for you.
The Problem: Deleted PHP Code That Still Executes
While refactoring TFOL’s Imagick-first image resizing pipeline, I temporarily added debug output to verify configuration:
echo "Driver=" . IMAGE_DRIVER;echo "MaxDim=" . IMAGE_MAX_DIM;
The output appeared correctly on the Edit Story admin page.
I then removed the lines.
Reloaded the page.
The output was still there.
At this point, debugging instincts kick in.
First Diagnosis: Twig Cache (Reasonable, But Wrong)
Twig templates are compiled into PHP and often cached, so the obvious assumption was:
“Twig cache isn’t clearing.”
I tried:
-
clearing
var/cache -
restarting LAMPP
-
full project search in VS Code
VS Code search returned zero results.
Yet the browser kept printing the debug output.
This is where debugging becomes psychological.
The Turning Point: Trust the Filesystem, Not the Editor
Instead of relying on the editor, I ran a direct filesystem search:
grep -R --line-number "Driver=" /opt/lampp/htdocs/focus-local
Result:
/opt/lampp/htdocs/focus-local/templates/work.html:5echo "Driver=" . IMAGE_DRIVER . "<br>";
The line did exist.
PHP was executing it.
Twig was not lying.
My editor was.
The Root Cause: Two Project Copies, One Name
The key discovery came from comparing paths:
-
VS Code workspace:
/opt/lampp/htdocs/focus_local/ -
Apache document root:
/opt/lampp/htdocs -
Served file:
/opt/lampp/htdocs/focus-local/templates/work.html
The difference was subtle but fatal:
👉 focus_local vs focus-local
I was editing one copy of the project in VS Code while Apache (LAMPP) was serving a different one.
Both directories looked legitimate.
Only one was real.
The Fix: Edit the File PHP Is Actually Running
Opening the served file directly confirmed everything:
nano /opt/lampp/htdocs/focus-local/templates/work.html
The phantom debug lines were right there.
I deleted them.
Saved.
Reloaded.
The output vanished instantly.
No cache clearing required.
No restart required.
The Lesson: Editors Can Lie, Paths Do Not
This was not:
-
a Twig bug
-
a PHP bug
-
a VS Code bug
It was a path mismatch bug, caused by assumptions during local development with LAMPP.
When debugging PHP/Twig applications, always remember:
The One-Line Truth Serum
echo __FILE__;
That line tells you exactly which file PHP is executing, regardless of what your editor shows.
Why This Matters in Real Projects
This mistake can happen easily when:
-
migrating projects
-
cloning repos multiple times
-
switching between Windows and Linux
-
renaming folders
-
working inside
/opt/lampp/htdocs
Editing the wrong copy of a site is one of the most dangerous development errors—because everything looks correct until production behavior disagrees.
Debugging Checklist (Bookmark This)
Before assuming cache, framework, or PHP bugs:
-
✅ Verify
$_SERVER['DOCUMENT_ROOT'] -
✅ Print
__FILE__ -
✅ Confirm VS Code workspace path
-
✅ Confirm Apache/LAMPP docroot
-
❌ Don’t trust editor search alone
Final Thought
When code appears after you delete it, the system isn’t haunted.
You’re just editing the wrong universe.
— Geoff Stevens, still trusting grep more than his eyes
Posted in ghost-stories by TFOL BLOG