I was absent from Grav for some time and wanted to continue develoment. About two or three years ago I could simply place a dump() command inside a PHP file and saw the content in the browser. This is not the case any more. I see nothing. Any ideas?
I tried it on a hosted site where it worked in the past as well as on a fresh local installation on my laptop. It runs Arch with php7-apache, php7-fpm, php7-gd using built-in symfony.
So it looks like that code block is being run. Since this is part of Admin and that has lots of tricky JS and CSS and AJAX, I think it might be the first option I suggested.
Sometimes I have added die(); after the dump() when I suspect my dump output is being obscured.
Thank you very much for that hint. When I add die(); I can see the dump. It's not very comfortable, but it will help.
What about logging variable contents to log file or debugbar? The documentation didn't help me much, as the PHP examples only output some textstrings. How do I use it for more complicated PHP types?
@myscha:
How do I use it for more complicated PHP types?
I don't know, but here are some suggestions:
remove die() and view the page source (it's obscured in rendering but should be in there somewhere); browser 'Inspect' might show something semi-readable too
enclose your ugly dumped output before die() with <pre>...</pre>
use the other debugger "clockwork" - I understand that it's much better (you'd need to use $this->grav['debugger']->addMessage($myvariable) from PHP)
try Xdebug if it's available - have only just started with this and have not got everything working yet.
@hughbris:
use the other debugger “clockwork” - I understand that it’s much better (you’d need to use $this->grav['debugger']->addMessage($myvariable) from PHP)
Thanks. I doubt you can help in my situation, but here's why I think I'm having trouble in a nutshell:
I'm accessing PHP in docker containers from VSCode on the host. I have Xdebug info output and can dump but not step debug. The step debugger is enabled but unable to connect to the configured "client". Online guides tell me not to open a port on the docker container, so I am assuming VSCode is the "server" here.
I am probably wasting time because I am confused which is server and which is client.
I am probably wasting time because I don't understand whether I should set Xdebug up in the browser or VSCode or both. I'm trying both.
The VSCode config/launch UI is pretty confusing and the settings.json file is not exactly self documenting. I think my "path to PHP" setting might need a special value.
This is all a diversion from the original question and I don't expect that you can help. I wanted to explain what I am finding difficult. Some online resources have helped me progress but there still seem to be significant gaps in my understanding of how this should work.
I've never used Docker (I'm using WSL on Windows 11), so indeed I might not be of much help in you situation.
This is all a diversion from the original question
I've changed the title to: How to debug using dump and xdebug?
Might it be an idea to start getting XDebug running on a environment without Docker? Just to get a feel of how things interop. Once you've got that working, you can add the complexity of Docker.
Thanks, it's because I know your environment is nothing like mine that I doubted you could help.
@pamtbaau:
Might it be an idea to start getting XDebug running on a environment without Docker?
It would confirm that Docker is the problem. However I try to use Docker for server functions to keep my desktop clean and I'm reluctant to lose that. It's a double edged sword, I agree.
Thanks for your offers and the link but it's not quite what I'm looking for.