set -x (bash) equivalent for PHP?

Good evening!

I'm looking to debug PHP code, I would normally go by the means of: echo "Step 1\n"; And/or using print_r / var_dump on specific variables.

But is there a 'set -x' ( bash ) equivalent for PHP?

That would make things a lot easier at times, at least it has helped me troubleshoot bash scripts.

If there isn't, what would be my best next steps to debug vanilla php mixed with some packages added with composer ( OOP coded parts )

Thanks in advance.

Posted Sep 12, 2022, 5:42 PM UTC

15
eurosat7•

Run with xdebug extension installed and activated. Set break points. Step trace. Easily done with phpstorm.

3
DanielB1990OP•

Thanks! Will look into xdebug, I use VSCode but probably will be able to get there too without PHPStorm 👍🏻

2
eurosat7•

gl&hf

2
[deleted]•

[deleted]

1
DanielB1990OP•

I'm aware, but I'm basically looking for ' full verbosity ' debugging

2
bobd60067•

Sorry, my previous answer (that I have since deleted) was wrong.

I've written php scripts that do what you described, but it's basically manual. That is, I look for a "-debug" command line option and use it to set a flag that I then use to execute all the echo statements or not.

There's probably a more elegant way to do it.

2