Search by

konradmichalik / typo3-outbound

konradmichalik

Outbound - Declarative API clients for TYPO3: describe external APIs as PHP interfaces with attributes, with retries, caching, rate limits, format profiles and safe defaults.

Package info

github.com/konradmichalik/typo3-outbound

Type:typo3-cms-extension

pkg:composer/konradmichalik/typo3-outbound

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-11-23 15:53 UTC

This package is auto-updated.

Last update: 2026-11-23 15:55:14 UTC


README

Extension icon

TYPO3 extension typo3_outbound

Latest Stable Version TYPO3 Supported PHP Versions CGL Coverage Tests License

This extension lets you describe external APIs as PHP interfaces with attributes and generates the implementation. Your code calls methods and receives typed objects, without HTTP code of its own.

Note

The goal is to replace the hand-written service wrapper per API: you declare what an API offers, and timeouts, retries, caching and security come as safe defaults.

Outbound as in outgoing requests: your site calls the API.

Warning

This extension is at an early stage. Attributes and APIs may still change before 1.0, so try it in a pilot before relying on it in production.

✨ Features

  • Less code per API: one interface method per endpoint and typed DTOs instead of request classes and HTTP plumbing
  • Fast pages: responses are cached and tied to the page cache, and a write can clear the pages showing the changed data
  • Pages keep rendering when an API fails: short timeouts, safe retries, a circuit breaker and, if you allow it, stale data to bridge an outage
  • Secure by default: HTTPS only, allowed hosts, private networks blocked, secrets from the environment and redacted logs
  • Made for TYPO3: per-site credentials from site settings, the caching framework and console commands to inspect and call every endpoint
  • Quick start from OpenAPI: interfaces and DTOs generated from an OpenAPI document or a sample response
  • Tests without network: mocks by endpoint instead of URL, in unit and functional tests

🔥 Installation

Requirements

  • TYPO3 >= 13.4
  • PHP 8.2+
  • Symfony components 7.4

Composer

composer require konradmichalik/typo3-outbound

TER

Download the zip file from TYPO3 extension repository (TER).

🚀 Quick start

Declare the API as an interface carrying #[Connection] and annotate a method with an HTTP verb:

use KonradMichalik\Typo3Outbound\Attribute as Outbound;

#[Outbound\Connection(baseUri: 'https://api.weather.example.com')]
interface WeatherApi
{
    /** @return array{city: string, temperature: float} */
    #[Outbound\Get('/forecast/{city}')]
    public function forecast(string $city): array;
}

Inject the interface wherever you need it and call the method:

final readonly class ForecastService
{
    public function __construct(private WeatherApi $weather) {}

    public function temperatureIn(string $city): float
    {
        return $this->weather->forecast($city)['temperature'];
    }
}

That's it: temperatureIn('Dresden') sends GET https://api.weather.example.com/forecast/Dresden, checks the JSON response against the declared shape and reads its temperature. For larger responses, return a DTO class instead of an array shape. Every interface with #[Connection] or #[Resource] that your Configuration/Services.yaml resource covers becomes a service.

Everything else is opt-in on top of that. A larger API splits into resources, takes its base URI and secret from the site configuration, maps responses to DTOs, retries, caches and maps a 404 to null, all declared with attributes:

use KonradMichalik\Typo3Outbound\Value\{Secret, SiteSetting};

#[Outbound\Connection(baseUri: new SiteSetting('crm.baseUri'), allowedHosts: ['crm.example.com'])]
#[Outbound\Auth\Bearer(token: new Secret('crm.token'))]
#[Outbound\Retry(maxRetries: 2)]
interface CrmApi {}

#[Outbound\Resource('/contacts')]
interface ContactsApi extends CrmApi
{
    #[Outbound\Get('/{id}')]
    #[Outbound\Cache(lifetime: 600, tags: ['crm_contact_{id}'], staleOnError: 3600)]
    #[Outbound\OnStatus(404, returns: null)]
    public function find(int $id): ?ContactDto;
}

See Defining endpoints for connections, resources, parameters and return types, and Features for every opt-in attribute.

📚 Documentation

Full documentation lives in docs/:

Part What's inside
Defining endpoints Connections, resources, endpoints, parameters, return types, DTOs and naming: the only part you need to call an API
Features Caching, retries and timeouts, rate limits, circuit breaker, pagination, formats, deferred calls and API conventions
Operating it Installation, configuration, caches, the console commands and testing with mocks
Background Architecture, security model, performance figures and the comparison with Saloon
Migrating a wrapper How to replace an existing service wrapper step by step

Tip

Offering endpoints instead of consuming them? typo3-routing declares frontend endpoints with a #[Route] attribute on a controller method.

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 2.0 (or later).