woocommerce / wc-api-php

WooCommerce REST API PHP Library
https://packagist.org/packages/automattic/woocommerce
MIT License
528 stars 160 forks source link

Developing with Xdebug #312

Closed BrianHenryIE closed 2 years ago

BrianHenryIE commented 2 years ago

I'm trying to use Xdebug to step through code both in the client side that is using this library, and then in the server to inspect the received request.

I'm able to do this by adding XDEBUG_SESSION_START=1 to the request URL: I've edited the library on my machine to add it to the parameters, in src/WooCommerce/HttpClient/HttpClient.php:236, inside HttpClient::createRequest(), I've added:

$parameters['XDEBUG_SESSION_START'] = 1;

And that works fine. But it's going to be overwritten when I update the library, and also risks leaving it in in production code.

Is there a better way? I'm invoking Client::post() which doesn't allow specifying parameters.

claudiosanches commented 2 years ago

Hello @BrianHenryIE,

You can use $woocommerce->http->request($endpoint, $method, $params) instead, so you can control all params used. Or even extend or class, so it should last after updates as well. I hope it helps.