- Can I use IntegrationEngine with Laravel instead of Symfony? The package is Symfony-first, but I need Laravel compatibility.
- IntegrationEngine is explicitly designed for Symfony 7.0+ and leverages its dependency injection, bundles, and Flex system. While you could theoretically adapt it for Laravel, it would require significant refactoring of the core architecture, including replacing Symfony’s HttpClient, Cache, and DI components. For Laravel, consider alternatives like Spatie’s API integrations or custom solutions built on Guzzle or HTTP clients.
- How do I handle OAuth2 authentication with dynamic token refresh in IntegrationEngine?
- IntegrationEngine supports dynamic authentication via the `DynamicAuthHandler`, which automatically refreshes tokens when expired. Configure your OAuth2 client in the `integration_engine.yaml` under the `auth` section, and ensure your token cache (e.g., Redis) is shared across PHP processes to avoid rate-limiting. For edge cases like token revocation mid-request, implement a custom `AuthHandler` extending `DynamicAuthHandler` and override the `getToken` method.
- What’s the performance impact of using IntegrationEngine’s Gateway pattern for API calls?
- The Gateway pattern adds minimal overhead since it primarily routes requests through a facade without modifying the HTTP layer. However, if you need concurrent API calls (e.g., batch operations), the default REST adapter doesn’t support it. For high-performance scenarios, implement a custom `BatchClientInterface` adapter or use Symfony’s `HttpClient` with parallel requests. The package’s structure doesn’t inherently slow down requests but enforces consistency.
- How do I test integrations generated by IntegrationEngine? The TESTING.md guide seems Symfony-specific.
- IntegrationEngine provides tools to mock the `IntegrationRegistry` and `IntegrationEngine` for unit testing. Use Symfony’s `HttpClientMock` to simulate API responses in your tests, and verify that `Action` classes return the expected `Response` DTOs. For integration tests, mock the entire `IntegrationGateway` and assert domain logic without hitting real APIs. The package’s strict structure makes testing predictable, but you’ll need to adapt your test suite to its facade-based design.
- Does IntegrationEngine support SOAP APIs, or is it REST/GraphQL-only?
- While IntegrationEngine includes built-in adapters for REST and GraphQL, it’s designed to be extensible for other protocols like SOAP. You can create a custom `ClientAdapterInterface` implementation for SOAP (e.g., using libraries like `php-soap`) and register it in the `integration_engine.yaml` under the `adapters` section. The scaffolding command (`make:integration`) will generate the necessary classes, and you’ll need to implement the `send` method to handle SOAP requests.
- What’s the upgrade path if my Symfony app is on 6.x but I want to use IntegrationEngine?
- IntegrationEngine requires Symfony 7.0+ and PHP 8.2+, so upgrading is necessary. Focus on updating Symfony’s core components (HttpClient, Cache, Dependency Injection) first, as these are the primary dependencies. The package’s documentation and Symfony’s upgrade guide will help identify breaking changes. If your app relies heavily on deprecated Symfony 6.x features, consider a phased migration or a custom wrapper layer to isolate IntegrationEngine’s dependencies.
- How do I handle API rate limits or retries in IntegrationEngine?
- IntegrationEngine doesn’t include built-in retry logic, but you can leverage Symfony’s `HttpClient` features. Configure retry policies in your `integration_engine.yaml` under the `http_client` section using Symfony’s `RetryStrategy`. For rate-limiting, use the `RateLimiter` interface to throttle requests or implement a custom `ClientAdapterInterface` that enforces delays. The package’s structure allows you to inject these behaviors at the adapter level.
- Can I share DTOs or mappers between multiple integrations to avoid duplication?
- Yes, IntegrationEngine encourages reusing DTOs across integrations by placing shared classes in a `Dto/` directory at the root of your `Integrations` folder. For mappers, you can extend the base `Mapper` class and reuse logic in multiple `Action` classes. The scaffolding command (`make:integration`) will generate the necessary files, and you can manually refactor shared logic into base classes or traits.
- How does IntegrationEngine handle errors or failed API responses?
- IntegrationEngine throws exceptions for failed requests (e.g., `IntegrationException` for HTTP errors or `MapperException` for invalid responses). These exceptions extend Symfony’s `Problem` class, making them compatible with Symfony’s error handling. Configure global error handling in your Symfony app to log or alert on these exceptions. The package uses Symfony’s `LoggerInterface`, so you can integrate with tools like Monolog or Sentry for observability.
- What are the alternatives to IntegrationEngine for Symfony API integrations?
- Alternatives include Symfony’s built-in `HttpClient` for simple integrations, libraries like `nelmio/api-client-bundle` for REST APIs, or custom solutions using Guzzle. For GraphQL, consider `overblog/graphql-bundle`. Unlike IntegrationEngine, these options lack scaffolding, strict structure, or anti-corruption layers. If you need a balance between flexibility and structure, `nelmio/api-client-bundle` is a lighter alternative, but it doesn’t enforce the same architectural discipline.