Laila
Laila

Reputation: 1501

Debugging Magento API Calls with XDebug

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 !

Upvotes: 5

Views: 1997

Answers (2)

Victor Zubcu
Victor Zubcu

Reputation: 1

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.

Upvotes: 0

Igris Dankey
Igris Dankey

Reputation: 411

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

Upvotes: 3

Related Questions