0

I am using cakephp 3.x . I have added my custom panel in debug-kit show my custom data here. This panel will show the URLs - to which HTTP client send the request.

Any Idea to proceed??

If i need to added any callback function or any additional event to get URL from Cake\Network\Http\Adapter\Stream and log it to my custom debug panel. I am working on debug panel first-time so no can i show HTTP Client URL to debug panel.

Only i have found this, where i can track the requested URL as $url in below code:

/**
 * Helper method for doing non-GET requests.
 *
 * @param string $method  HTTP method.
 * @param string $url     URL to request.
 * @param mixed  $data    The request body.
 * @param array  $options The options to use. Contains auth, proxy etc.
 *
 * @return \Cake\Network\Http\Response
 */
protected function _doRequest($method, $url, $data, $options)
{   debug(urldecode($url));
    $request = $this->_createRequest($method, $url, $data, $options);

    $time = microtime();
    $timerKey = 'debug_http.call.' . $url . '.' . $time;
    if (Configure::read('debug')) {
        DebugTimer::start($timerKey, $method . ' ' . $url);
    }

    $response = $this->send($request, $options);

    if (Configure::read('debug')) {
        DebugTimer::stop($timerKey);
        ClientCallPanel::addCall($request, $response, DebugTimer::elapsedTime($timerKey));
    }

    return $response;
}

Waiting for experts' response...

ndm
  • 59,784
  • 9
  • 71
  • 110
sssurii
  • 750
  • 4
  • 17

1 Answers1

1

Look at how the built-in panels like LogPanel, TimerPanel, SqlPanel, etc do things, they use loggers and events to gather the data.

I'd suggest that you go the same route to decouple your custom panel from your HTTP client, ie add configurable logging capability where your panel could hook in by registering a logger that captures the specific level and/or scope used by the HTTP client, or make your client dispatch events that your panel can subscribe to.

See also

ndm
  • 59,784
  • 9
  • 71
  • 110