Symfony SDK

The Symfony bundle automatically tracks all HttpClient calls and provides a tracked Guzzle client.

Installation

composer require outboundiq/symfony-bundle

Configuration

1. Register the bundle in config/bundles.php:

return [
    // ... other bundles
    OutboundIQ\Symfony\OutboundIQBundle::class => ['all' => true],
];

2. Create config/packages/outboundiq.yaml:

outboundiq:
    api_key: '%env(OUTBOUNDIQ_KEY)%'
    enabled: true
    auto_user_context: true
    ignored_hosts:
        - 'localhost'
        - '127.0.0.1'

3. Add to .env:

OUTBOUNDIQ_KEY=your_api_key_here

Automatic Tracking (HttpClient)

use Symfony\Contracts\HttpClient\HttpClientInterface;

class PaymentService
{
    public function __construct(private HttpClientInterface $httpClient) {}

    public function charge(): array
    {
        // Automatically tracked!
        $response = $this->httpClient->request('POST', 'https://api.stripe.com/v1/charges', [
            'json' => ['amount' => 2000],
        ]);
        return $response->toArray();
    }
}

Guzzle Tracking

For Guzzle, inject TrackedGuzzleClient:

use OutboundIQ\Symfony\Http\TrackedGuzzleClient;

class PaymentService
{
    public function __construct(private TrackedGuzzleClient $guzzle) {}

    public function charge(): array
    {
        // Automatically tracked!
        $response = $this->guzzle->post('https://api.stripe.com/v1/charges', [
            'json' => ['amount' => 2000],
        ]);
        return json_decode($response->getBody()->getContents(), true);
    }
}

Test Your Integration

php bin/console outboundiq:test
Symfony SDK | OutboundIQ Docs