.claude/skills/ecotone-business-interface/SKILL.md
Creates Ecotone business interfaces (gateways): DBAL query interfaces with #[DbalBusinessMethod], repository abstractions, expression language parameters, and media type converters. Use when creating database query interfaces, custom repository gateways, data converters, or abstract interface-based message sending with BusinessMethod.
npx skillsauth add ecotoneframework/ecotone-dev ecotone-business-interfaceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Business interfaces let you declare PHP interfaces that Ecotone auto-implements at runtime. They cover database queries (DBAL), type converters, messaging gateways (BusinessMethod), and repository abstractions. Use this skill when you need to create any of these interface-driven patterns.
use Ecotone\Dbal\Attribute\DbalQueryBusinessMethod;
use Ecotone\Dbal\Attribute\DbalWriteBusinessMethod;
use Ecotone\Dbal\DbaBusinessMethod\FetchMode;
interface OrderRepository
{
#[DbalQueryBusinessMethod('SELECT * FROM orders WHERE order_id = :orderId')]
public function findById(string $orderId): ?array;
#[DbalQueryBusinessMethod(
'SELECT * FROM orders WHERE status = :status',
fetchMode: FetchMode::ASSOCIATIVE
)]
public function findByStatus(string $status): array;
#[DbalWriteBusinessMethod('INSERT INTO orders (order_id, product, status) VALUES (:orderId, :product, :status)')]
public function save(string $orderId, string $product, string $status): void;
}
use Ecotone\Messaging\Attribute\Converter;
class OrderConverter
{
#[Converter]
public function fromArray(array $data): OrderDTO
{
return new OrderDTO(
orderId: $data['order_id'],
product: $data['product'],
status: $data['status'],
);
}
#[Converter]
public function toArray(OrderDTO $order): array
{
return [
'order_id' => $order->orderId,
'product' => $order->product,
'status' => $order->status,
];
}
}
The framework auto-discovers converters and uses them for type conversion in message handling.
BusinessMethod is an interface-only attribute -- Ecotone auto-generates an implementation that sends messages through the messaging system. The requestChannel routes to the matching handler's routing key.
use Ecotone\Messaging\Attribute\BusinessMethod;
interface NotificationGateway
{
#[BusinessMethod('notification.send')]
public function send(string $message, string $recipient): void;
}
use Ecotone\Messaging\Attribute\ServiceActivator;
class NotificationHandler
{
#[ServiceActivator('notification.send')]
public function handle(string $message): void
{
// Process notification
}
}
BusinessMethod interfaces can be injected as parameters into CommandHandler methods for cross-aggregate communication:
use Ecotone\Messaging\Attribute\BusinessMethod;
use Ecotone\Modelling\Attribute\Identifier;
interface ProductService
{
#[BusinessMethod('product.getPrice')]
public function getPrice(#[Identifier] string $productId): int;
}
#[EventSourcingAggregate]
class Basket
{
#[CommandHandler]
public static function addToNewBasket(
AddProductToBasket $command,
ProductService $productService
): array {
return [new ProductWasAddedToBasket(
$command->userId,
$command->productId,
$productService->getPrice($command->productId)
)];
}
}
Use #[Reference] for explicit service container injection when it is not the first service parameter.
Ecotone attributes support expressions for dynamic behavior:
use Ecotone\Modelling\Attribute\CommandHandler;
class OrderService
{
#[CommandHandler(routingKey: "payload.type")]
public function handle(array $payload): void { }
}
Available variables: payload (message payload), headers (message headers).
Ecotone auto-generates repositories for aggregates. For custom repositories:
use Ecotone\Modelling\Attribute\Repository;
#[Repository]
interface CustomOrderRepository
{
public function findOrder(string $orderId): ?Order;
public function saveOrder(Order $order): void;
}
:paramName)#[Converter] methods are auto-discovered -- no manual registration needed#[Reference] for non-first service parametersAPI reference -- Attribute constructor signatures and parameter lists for DbalQueryBusinessMethod, DbalWriteBusinessMethod, DbalParameter, BusinessMethod/MessageGateway, FetchMode constants, and MediaType constants. Load when you need exact constructor parameters, types, or defaults.
Usage examples -- Complete, runnable code examples for all business interface patterns: advanced DBAL queries with parameter type conversion and expressions, write operations, JSON converters, BusinessMethod with headers and routing, cross-aggregate injection with #[Reference], custom connection references. Load when you need full class implementations or advanced variations beyond the basic patterns above.
Testing patterns -- How to test business interfaces with EcotoneLite::bootstrapFlowTesting(), including gateway retrieval via getGateway(), DBAL interface testing setup, and converter testing patterns. Load when writing tests for business interfaces.
development
Implements workflows in Ecotone: Sagas (stateful process managers), stateless workflows with InternalHandler and outputChannelName chaining, and Orchestrators (Enterprise) with routing slip pattern. Use when building Sagas, process managers, multi-step workflows, long-running processes, handler chaining, or Orchestrators.
development
Writes and debugs tests for Ecotone using EcotoneLite::bootstrapFlowTesting, aggregate testing, async-tested-synchronously patterns, projections, and common failure diagnosis. Use when writing tests, debugging test failures, adding test coverage, or implementing any new feature that needs tests. Should be co-triggered whenever a new handler, aggregate, saga, projection, or interceptor is being implemented.
testing
Sets up Ecotone in a Symfony project: composer installation, bundle registration, YAML configuration, Doctrine ORM integration, SymfonyConnectionReference for DBAL, Symfony Messenger channels, async consumer commands, and ServiceContext. Use when installing Ecotone in Symfony, configuring Symfony-specific connections, or setting up Symfony async consumers.
development
Implements message resiliency in Ecotone: RetryTemplateBuilder for retry strategies, error channels, ErrorHandlerConfiguration, DBAL dead letter queues, outbox pattern for guaranteed delivery, and FinalFailureStrategy for permanent failures. Use when handling failed messages, configuring retries, setting up dead letter queues, implementing outbox pattern, or managing error channels.