carlosgude / integration-engine
Connect external APIs to Symfony through configurable adapters, without writing repetitive clients.
Package info
github.com/CarlosGude/integrationEngine
Type:symfony-bundle
pkg:composer/carlosgude/integration-engine
Requires
- php: >=8.2
- psr/clock: ^1.0
- psr/event-dispatcher: ^1.0
- psr/log: ^2.0|^3.0
- symfony/console: ^6.4|^7.0|^8.0
- symfony/dependency-injection: ^6.4|^7.0|^8.0
- symfony/http-client: ^6.4|^7.0|^8.0
- symfony/http-foundation: ^6.4|^7.0|^8.0
- symfony/yaml: ^6.4|^7.0|^8.0
Requires (Dev)
- deptrac/deptrac: ^4.7
- friendsofphp/php-cs-fixer: ^3.0
- infection/infection: ^0.33.2
- phpstan/phpstan: ^2.2
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.0
- symfony/framework-bundle: ^6.4|^7.0|^8.0
- symfony/http-kernel: ^6.4|^7.0|^8.0
- symfony/remote-event: ^6.4|^7.0|^8.0
- symfony/webhook: ^6.4|^7.0|^8.0
Suggests
- symfony/messenger: Dispatch remote events through the webhook endpoint.
- symfony/remote-event: Typed inbound remote events.
- symfony/webhook: Inbound webhook parsing and Symfony endpoint integration.
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v9.4.0
- v9.3.1
- v9.3.0
- v9.2.0
- v9.1.0
- v9.0.0
- v8.0.4
- v8.0.3
- v8.0.2
- v8.0.1
- v8.0.0
- v7.0.2
- v7.0.1
- v7.0.0
- v6.0.0
- v5.4.0
- v5.3.1
- v5.3.0
- v5.2.0
- v5.1.0
- v5.0.0
- v4.1.0
- v4.0.0
- v3.0.0
- v2.3.1
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.0
- v1.27.1
- v1.27.0
- v1.26.0
- v1.25.5
- v1.25.4
- v1.25.3
- v1.25.2
- v1.25.1
- v1.25.0
- v1.24.0
- v1.23.0
- v1.22.0
- v1.20.0
- v1.19.0
- v1.18.0
- v1.17.0
- v1.16.1
- v1.16.0
- v1.15.1
- v1.14.0
- v1.13.0
- v1.12.0
- v1.11.0
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- dev-docs/single-file-docs-generator
- dev-feat/response-received-event
This package is auto-updated.
Last update: 2026-10-22 16:20:19 UTC
README
Latest tagged release: see releases Requirements: PHP 8.2+ ยท Symfony 6.4 / 7.x / 8.x Website: integrationengine.dev Documentation: docs/documentation.md Roadmap: docs/roadmap.md
IntegrationEngine is a Symfony bundle for keeping outbound API integrations predictable: actions describe requests, mappers turn external responses into typed DTOs, and the engine owns the repetitive transport/authentication pipeline.
This README documents the current code in the repository. CHANGELOG.md is the source of truth for release history and unreleased changes.
What the bundle standardizes
An integration is built from a small set of contracts:
- an
AbstractActionper operation; - optional
ActionBodyInterface/ActionContextInterfacevalues for runtime input; - one
AbstractMapperfor each action that returns data; - a typed
ResponseInterfaceDTO; - an integration facade in the consuming application, backed by
IntegrationRegistry.
The bundle then handles configuration lookup, path resolution, static or dynamic auth, connection overrides, middleware, HTTP transport, batching, response mapping and lifecycle events.
It intentionally does not own your domain model. Keep the external DTOs behind a Gateway / Anti-Corruption Layer when they cross into application or domain code.
When not to use it
IntegrationEngine is a poor fit when an API needs a highly stateful SDK, protocol-specific streaming/session behavior, or a vendor library that already owns transport, retries and object mapping coherently. In those cases, wrapping the SDK behind your own application boundary is usually simpler than forcing it into this action/mapper model.
Why this exists
Integrations tend to accumulate their own ad-hoc HTTP client, their own way of attaching auth, and their own untyped response handling, repeated slightly differently for every external API a project talks to. That inconsistency shows up as duplicated token logic, DTOs that drift from what the API actually returns, and observability that exists for some integrations and not others. This bundle grew out of exactly that pattern in a production integration, not from a speculative design exercise. The response is a small, uniform contract โ Action, Mapper, Response โ so every integration looks like every other one and can be tested in isolation.
Install
composer require carlosgude/integration-engine
With Symfony Flex, the bundle is registered automatically. Without Flex, add IntegrationEngine\Bundle\IntegrationEngineBundle::class => ['all' => true] to config/bundles.php.
First integration
Generate the integration shell and first action:
php bin/console make:integration MyApi GetEmployee
The command creates the integration facade, action, mapper/response when applicable, and the integration YAML. On the first integration it can also create config/packages/integration_engine.yaml.
Bundle configuration is per integration:
# config/packages/integration_engine.yaml integration_engine: integrations: my_api: base_url: 'https://api.example.com' config_path: '%kernel.project_dir%/src/Infrastructure/Integrations/MyApi/MyApi.yaml'
Action configuration lives in the integration YAML:
GetEmployee: action: App\Infrastructure\Integrations\MyApi\GetEmployee\Request\GetEmployeeAction method: GET path: /employees/{id}
At the lowest level, calling an action is a single send() through the registry:
use IntegrationEngine\Core\Contract\Action\DefaultActionContext; $response = $registry->get('my_api')->send( actionName: GetEmployeeAction::getName(), context: DefaultActionContext::create(['id' => $id]), );
In practice, wrap that behind a small facade instead of calling IntegrationRegistry directly from controllers and application services, so callers get a typed return instead of the base ResponseInterface.
The facade implements IntegrationName so the integration is referenced as MyApiIntegration::NAME rather than a bare string โ the constant is autocompleted and can be grepped/refactored with the rest of the codebase, instead of relying on string literals that silently drift. The registry rejects a blank name and the interface's placeholder value, so every facade declares its own. This is the recommended facade pattern:
use IntegrationEngine\Core\Contract\Action\DefaultActionContext; use IntegrationEngine\Core\Registry\IntegrationName; use IntegrationEngine\Core\Registry\IntegrationRegistry; final class MyApiIntegration implements IntegrationName { public const NAME = 'my_api'; public function __construct(private IntegrationRegistry $registry) {} public function getEmployee(int $id): GetEmployeeResponse { $response = $this->registry->get(self::NAME)->send( actionName: GetEmployeeAction::getName(), context: DefaultActionContext::create(['id' => $id]), ); if (!$response instanceof GetEmployeeResponse) { throw new \LogicException('Unexpected response type.'); } return $response; } }
A failed call (HTTP 4xx/5xx, or a network error) throws RequestResponseException, which carries the status code and context (all exceptions):
use IntegrationEngine\Core\Exception\RequestResponseException; try { $response = $this->registry->get(self::NAME)->send(/* ... */); } catch (RequestResponseException $e) { // $e->statusCode, $e->context }
See Getting started for the request, context, auth, mapping and batch contracts.
Current capabilities
| Area | Current contract | Reference |
|---|---|---|
| REST | Built-in Symfony HttpClient adapter; JSON by default | HTTP clients |
| Form bodies | FormEncodedBodyInterface, or client: form_encoded for an all-form API |
Form bodies |
| GraphQL | GraphQLBodyInterface; body is sent as query + variables |
HTTP clients |
| Batch | sendMany() isolates failures; built-in REST, GraphQL and form adapters support concurrent dispatch when request middleware does not force the sequential fallback |
Batch requests |
| Auth | bearer/basic/API key; dynamic token action with cache + one fresh-token retry after a cached-token 401 | Authorization |
| Multi-connection | ConnectionResolverInterface can override base URL/auth and namespace token caches per call |
HTTP clients |
| Middleware | action-level client middleware plus full-request middleware for signing | Middleware |
| Response caching | per-action cache_ttl over the raw response |
Response caching |
| Resilience | transport timeout, max duration and Symfony retry configuration | Resilience |
| Outgoing security | hostname allowlist and optional private-network blocking for built-in transports | Security |
| Observability | scalar-only request, response, failure, token and webhook events | Lifecycle events |
| Webhooks | YAML definition, HMAC verification, typed mapper, Symfony Webhook/RemoteEvent integration | Webhooks |
| Static analysis | optional PHPStan rules for mapper reciprocity, response modifiers and facade return types | PHPStan |
| Debugging | debug:integration [name] and Symfony profiler integration in debug mode |
Debugging |
| Errors | typed exceptions; RequestResponseException carries status and context |
Errors |
Configuration split
Bundle configuration decides how an integration is wired; the integration YAML describes what operations that integration exposes. Every key is in docs/configuration.md.
Architecture in one sentence
Core defines contracts and orchestration; Infrastructure implements adapters; Bundle wires Symfony; compatibility shims stay outside Core; optional PHPStan rules live in their own extension layer. The dependency direction is enforced by Deptrac.
The detailed dependency rules and runtime pipeline are in architecture.md.
Quality
Repository gates cover style, PHPStan, PHPUnit, Deptrac and Infection. Measured results belong in docs/advanced/quality.md, not in this README, so release copy does not become a museum of stale numbers.
Demo
integrationEngine-demo is the consuming Symfony application used to demonstrate and contract-test the bundle.
Further reading
Start from docs/documentation.md, the only documentation index. It also lists the Architecture Decision Records (why a design was chosen) and the upgrade guide for each major version. Archived plans, audits and spikes under docs/archived/ are explicitly non-current.