I am going to show using Xdebug with Docker. Because, as long as you prefer using Xdebug on development workspace with Docker, you have to create r...
For further actions, you may consider blocking this person and/or reporting abuse
I see that you put xdebug config direct in dockerfile it's bad approach. You can create a file
called xdebug.ini it can look like the following:
[Xdebug]
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.default_enable=0
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000
xdebug.remote_connect_back=0
xdebug.profiler_enable=0
xdebug.remote_log="/tmp/xdebug.log"
xdebug.profiler_output_dir="/var/www/html/profiler"
xdebug.profiler_output_name="cachegrind.out.%p"
xdebug.cli_color=1
xdebug.profiler_append=1
after that copy that one into /usr/local/etc/php/conf.d/
This is a lot cleaner, also since we use prebuilt docker images we cant just change the dockerfile. I've not been able to get it to work the way you explained, but i'll try again later ;)
Thank you for reply, it's prettier solution as you said.
I've used this
xdebug.ini
placed in/usr/local/etc/php/conf.d/
Where
host.docker.internal
is the proper way to access your host ip address in a containerized app in Docker Desktop clients.Also you need to add the next line to your Dockerfile or set
environment
field indocker-compose.yml
After that you need to press "Start listen on PHP debug connections" (phone icon), set a breakpoint and start a debug session (bug icon). To trigger the debug session you access your API endpoint via GET, POST, with query param
?XDEBUG_SESSION_START=PHPSTORM
or cookie set toXDEBUG_SESSION = PHPSTORM
. To set this cookie easily you can use Xdebug Helper extension or a similar one.Thank you so much for this guide! I was struggling all day to make my Wordpress in Docker on Windows setup work with xdebug. This post had all the missing details like how to have xdebug connect to PhpStorm running on the host.
I'm glad to hear that, happy coding :)
Why you use the big php.ini like this. Something looks unnecessary.
yep, I just wanted the audience to know we can do.
Hello Dear! In my case ,following your last point, browser keeps loading. But debbuger variables area is not being populated. Can you please help
Hi! Is there any error? How can I help you with it?
There is no error. But variables are not also being shown in debugger area.
I am not using Symphony, but a simply all code is in index.php file within app/public folder as specified by you. Can there be any mapping issue in this case? My mappings are same as specified by you