5

I have to debug an application (let's call it App A) that communicates with a Magento store through API v1 (via a Zend_XmlRpc_Client).

Here's how XDebug is configured on my php.ini.

xdebug.remote_enable = 1
xdebug.remote_host = 10.0.2.2
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.idekey=PHPSTORM
xdebug.trace_enable_trigger = 1
xdebug.trace_output_dir = "/var/www/xdebug_profile"
xdebug.profiler_enable_trigger = 1
;xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "/var/www/xdebug_profile"
xdebug.remote_log = "/var/www/xdebug_profile/xdebug.log"

When I go to my Magento store through my browser and enable debugging (using Xdebug chrome extension), I can debug my Magento store.

I would like to do the same thing from my App A. I want to access to my App A through my browser and be able to debug the Magento code that is executed through API calls. I tried to pass a cookie to the XML RPC client this way (following this article: http://inchoo.net/magento/magento-xdebug/ ) :

$xmlrpc_client->getHttpClient()->setCookie('XDEBUG_SESSION', 'PHPSTORM');

But it's not working. I also tried XDEBUG_SESSION_START for the cookie name, I tried to pass ?XDEBUG_SESSION_START=PHPSTORM at the end of the URL that my client calls and it's not working either.

FYI, I'm using a vagrant environment, both applications are using the same IP. Here's the content of my /etc/hosts file :

<my_vagrant_ip_address> dev.mysuperstore.com dev-app-a.mysuperstore.com 

Any help is highly appreciated !

Laila
  • 1,421
  • 3
  • 13
  • 27
  • 1) What does xdebug log says? Does it even tries to debug or not? 2) Try with `xdebug.remote_autostart = 1` so that xdebug will attempt to debug every single request – LazyOne May 14 '15 at 18:07
  • P.S. You may emulate your API calls using PhpStorm's Test RESTFull tool or POSTman (e.g. Chrome's app), for example http://stackoverflow.com/a/19147935/783119 – LazyOne May 14 '15 at 18:12
  • Here's what the logs says : Log opened at 2015-05-14 18:40:42 I: Checking remote connect back address. I: Remote address found, connecting to 192.168.56.101:9000. E: Could not connect to client. :-( Log closed at 2015-05-14 18:40:42 Using Postman would not be very convenient for me, I have to deal with "complex" objects structure. – Laila May 14 '15 at 18:41
  • So .. xdebug connects but IDE is either does not listen for connections .. or reached the simultaneous debug connection limit (check IDE settings) or you have firewall in a way (that's if IP is correct, of course). – LazyOne May 14 '15 at 18:46

2 Answers2

1

Just add ?XDEBUG_SESSION_START=filter_string at the end of the url

https://{{url_magento_test}}/rest/default/V1/task_blogext/posts?XDEBUG_SESSION_START=PHPSTORM
Igris Dankey
  • 383
  • 2
  • 6
0

All you need to add for get working debug is to add this lines in xdebug.ini and to connect it:

zend_extension=xdebug
[xdebug]
xdebug.mode=debug
xdebug.client_port=9000
xdebug.client_host=host.docker.internal
xdebug.discover_client_host=1

After this, install chrome extension debug helper, and press in it debug mod. And all will work great.