-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Debugging Application with Xdebug #1681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @aftabnaveed , Xdebug conflicts with swoole coroutine. We are developing a coroutine tracking and debugging tool now. Will be released later |
amazing |
@matyhtf |
@tarach |
If anything, you should probably base any debugging tool off the DBGp protocol, so that at least IDEs have instantaneous support for it, as it's the protocol that Xdebug uses: https://xdebug.org/docs-dbgp.php — feel free to reach out if you have questions regarding the protocol. |
@derickr When you were developing xdebug how were you debugging your extensions? I mean Swoole clearly has a conflict with debuggers. I'm guessing its because they all use the same entrypoint to the PHP/Zend engine. If I were to trace that issue watching line by line PHP startup process ( just like your extension allows me to do with PHP scripts ) what tools should I use? @matyhtf What kind of approach would you suggest for now? Does register_tick_function would work with Swoole ( I remember using it once or twice for debugging ) or maybe write code compatible with standard stack Apache / Nginx + PHP ? |
@tarach For debugging memory leaks and other issues, I'd use |
@matyhtf Has any progress been made in this regard? We really want to migrate from Swoole 2.0.x to Swoole 4.x but xdebug or debugging for that matter is a deal breaker for us at the moment. |
Bump? Is this still at least on a roadmap? |
Any progress to this feature? |
Is there a way to disable coroutines? The doc states: https://www.swoole.co.uk/coroutine
|
I'm with @nick-zh on providing the ability to disable coroutines for Xdebug compatibility purposes. |
Any progress to this feature? |
@lihe6666 are you having trouble using https://github.com/swoole/sdebug ? |
@nick-zh the documentation seems to be not very clear about it, what does it do? Does it replace xdebug? Does it support co-routines? |
@aftabnaveed it does replace xdebug if you are using swoole, yes. As to co-routines, i can't say since i don't use them, sry. If you find out, please let us know ✌️ |
@aftabnaveed Have you ever used xdebug? Sdebug is installed exactly the same way as xdebug. Perhaps you could first see how xdebug is used? It is my ini configuration: [root@592b0366acbf ~]# cat /etc/php.d/sdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
[root@592b0366acbf ~]# If you want to debug remotely, it is my configuration: /var/www/sdk # cat /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
[XDebug]
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000
xdebug.remote_enable=1 |
Thank you. |
Seems like this is not working with IDE Key.
|
@juslintek just to make sure, you are using sdebug with the branch |
@nick-zh I am using it, the thing is if I run sdebug. P.S. I removed xdebug, because it was crashing my whole PC. :D |
@juslintek alright thx, i will try to check this evening in a small test project if i can reproduce this. Have to be honest, didn't have to debug for a few weeks. But apart from getting it runnig for the first time, i had no problems. |
@nick-zh, well I'm using it inside a docker, maybe I should've mentioned that. :-) |
@juslintek yeah i figured and you are running osx on host, i noticed the |
@nick-zh Yes, I am, but I resolve that manually, that hostname points to the default gateway. |
So its 2020 now and apparently there is still no proper compatibility with Xdebug? |
Can you use this? If there is a problem, I will try to solve it: |
@juslintek @pavrip sry guys i totally forgot to provide my findings. So this seems to work fine with the current sdebug version on
Also you need to run the debug target in PHPStorm, before you start swoole. It seems if you start the debug target when swoole is already running, it doesn't work properly, at least for me. @huanghantao if you have any improvements to sdebug, a PR to |
@nick-zh if you start xdebug before docker image is runned then it gets stuck forever and never finishes loading, even though no breakpoints are set. :D My ide key is
Remote log says it is connected to sdebug client. But guess PHPStorm xdebug client doesn't recognise it or something and does not display anything.
P.S. I am using sdebug_2_9 branch. After setting: P.S. My PhpStorm version:
P.S. telnet is also from that docker container is able to connect to PHPStorm debug client. Seems like PHPStorm debug client is not doing anything for some reason... And if I stop xdebug client it is not able to do it anymore, which means that it is connecting to correct debug client. Basically it is really random and unstable, sometimes it works sometimes it doesn't. Sometimes it says mapping is bad and so on. But everything is fine. I create issue for same reason here: #3421 Even with So the only way I can use xdebug is write API tests for all endpoints and scenarios and run them with phpunit or something and add breakpoints where I want app to break. Basically as long as you skip swoole server all is fine. Sdebug doesn't work with swoole server... |
We recommend using https://github.com/swoole/yasd to debug |
@juslintek any luck on this? I'm also using laravel-s on a docker setup but unable to debug. Communication between container and IDE seems fine and even seems to start to capture something but it drops after a second or so. |
@juber-ivre it works randomly, you have to restart docker container or process or restart it, make sure no parallel connections exist and make sure ide accepts more then 4 xdebug connections. But usually what I do is just replay specific request from developer tools network tab. With phpunit there are no problems :-) |
It doesn't work with phpstorm, even tests fail. Left a issue regarding that: swoole/yasd#95 as I see it doesn't work with VSCode as well: swoole/yasd#94 And Sdebug does not support php8 :-( Its like a dead end. You have to fall back to cli coding... Thats a bad dev experience. |
curious if (and how) you were able to make yasd work with vs code? |
Any news on this front? Ditching XDebug is simply not an option. No other tool is going to get as much traction and IDE support. This is a show stopper... |
If you don't need the coroutines just disable it while debugging and the xdebug should work perfectly fine. |
No, it doesn't, sadly. We're running Laravel Octane on Swoole and XDebug won't connect to the IDE if running in Swoole. We had to build an awkward workaround to use the builtin PHP server in local development instead of Octane to be able to debug our application. |
Hi @Radiergummi , |
No worries @nprasath002. So what we do is a bit awkward, but works: Basically, we use the built-in PHP web server instead of Octane/Swoole in locale development. That is, our entry point script checks the configured environment and either spawns I'd very much prefer XDebug to work in Swoole, but that's how it is right now. set -e
role=${CONTAINER_ROLE:-web}
env=${APP_ENV:-production}
echo "Caching configuration for ${env}..."
php --define xdebug.mode=off artisan config:cache
if [ "$role" = "web" ]; then
rpc_port=${WEB_RPC_PORT:-6001}
listen_port=${WEB_LISTEN_PORT:-9000}
max_requests=${WEB_MAX_REQUESTS:-500}
worker_count=${WEB_WORKER_COUNT:-auto}
php --define xdebug.mode=off artisan view:cache
if [ "${env}" = "local" ]; then
exec php /app/artisan serve \
--port="${listen_port}" \
--host=0.0.0.0 \
"$@"
else
exec php /app/artisan octane:start \
--max-requests="${max_requests}" \
--workers="${worker_count}" \
--rpc-port="${rpc_port}" \
--port="${listen_port}" \
--server=swoole \
--host=0.0.0.0 \
"$@"
fi
fi |
Thanks @Radiergummi |
Hi, any progress here? Our project uses coroutine, so not using swoole in dev is not a option.:-) |
I know this sounds stupid, but you're probably better off wrapping that code in an |
Uh oh!
There was an error while loading. Please reload this page.
PHP Version 7.1.9
The documentation says that Swoole coroutine cannot be used with xdebug, while developling applications xdebug is very helpful tool. For smaller application it may not be a problem but larger applications makes it necessary to use it.
My question is how can I debug applications while still using Swoole Coroutines ?
The text was updated successfully, but these errors were encountered: