PHP code example of wucdbm / http-logger-bundle

1. Go to this page and download the library: Download wucdbm/http-logger-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wucdbm / http-logger-bundle example snippets


$log = $this->log('SomeClass::someMethod()');

try {
    $request = new Request('POST', 'https://someUri.com/API', [
        RequestOptions::BODY => 'SomeBody'
    ]);

    $this->logRequest($log, $request, RequestLogMessageType::ID_XML);

    $this->pool->sendAsync($request, function (ResponseInterface $response) use ($log) {
        try {
            $rawResponse = $response->getBody()->getContents();

            $this->logResponse($log, $response, RequestLogMessageType::ID_XML);

            $crawler = new Crawler($rawResponse);

            try {
                // do some Crawler work
            } catch (\InvalidArgumentException $ex) {
                $this->exception($log, $ex, $crawler->html());
            }
        } catch (\Throwable $ex) {
            $this->exception($log, $ex);
        }
    }, function (RequestException $ex) use ($log) {
        $this->requestException($log, $ex, RequestLogMessageType::ID_XML);
    });
} catch (\Throwable $ex) {
    $this->exception($log, $ex);
}



namespace Some\Name\Space;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="SomeRepositoryClass")
 */
class YourRequestLog extends \Wucdbm\Bundle\WucdbmHttpLoggerBundle\Entity\RequestLog {

    /**
     * @ORM\ManyToOne(targetEntity="Some\Name\Space\SomeOtherEntity", inversedBy="inverseSideField")
     * @ORM\JoinColumn(name="relation_id", referencedColumnName="id", nullable=alse)
     */
    protected $someOtherEntity;
    
}