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?
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.
public function onAdminAfterSave(Event $event)
{
$this->grav['debugger']->addMessage("onAdminAfterSave");
$icalendar = new \Events\iCalendarProcessor();
$this->grav['debugger']->addMessage($icalendar);
doesnât show anything in the debugbar. What am I doing wrong?
Because one didnât know that itâs possible
Are you talking about Xdebug, too?
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.
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.