/symfony-api-response
Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API, endpoint, controller, response, error handling, JSON, REST, API response, exception subscriber, HTTP
$ npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-api-response --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/symfony-api-response
Context preview
The summary Claude sees to decide when to auto-load this skill.
Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API, endpoint, controller, response, error handling, JSON, REST, API response, exception subscriber, HTTP
SKILL.md
symfony-api-response.SKILL.mddescription: "Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API, endpoint, controller, response, error handling, JSON, REST, API response, exception subscriber, HTTP"
Symfony API Response Standard
You are an expert in building standardized REST APIs within Symfony hexagonal architecture.
When to Activate
- User creates API endpoints or controllers
- User asks about response format or error handling
- User needs exception handling for APIs
- User mentions REST, JSON, or API design
Standard JSON Payload
ALL API responses use this format:
{
"result": null,
"error": null,
"extra": null,
"status": 200
}| Field | Type | Description | |-------|------|-------------| | `result` | `mixed` | Success data (null on error) | | `error` | `?object` | Error details (null on success) | | `extra` | `?object` | Metadata: pagination, debug info | | `status` | `int` | HTTP status code |
Success Response
{
"result": {"id": "uuid-123", "name": "John"},
"error": null,
"extra": null,
"status": 200
}Error Response
{
"result": null,
"error": {"code": "USER_NOT_FOUND", "message": "User not found"},
"extra": null,
"status": 404
}Debug Mode (APP_DEBUG=true)
{
"result": null,
"error": {"code": "INTERNAL_ERROR", "message": "Something went wrong"},
"extra": {"debug": {"exception": "...", "trace": "..."}},
"status": 500
}Controller Pattern
Controllers are thin — dispatch to buses only:
namespace App\Presentation\{Module}\API;
use App\Presentation\Shared\ApiResponseTrait;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
#[Route('/api/{module}')]
final class {Entity}Controller
{
use ApiResponseTrait;
public function __construct(
private readonly MessageBusInterface $commandBus,
private readonly MessageBusInterface $queryBus,
) {
}
#[Route('', methods: ['POST'])]
#[IsGranted('ROLE_...')] // ALWAYS include
public function create(Request $request): JsonResponse
{
// 1. Parse input
// 2. Create command
// 3. Dispatch to command bus
// 4. Return success response
}
}References
See `references/` for detailed guides:
- `payload-schema.md` — ApiResponseTrait, response helpers
- `exception-handling.md` — ExceptionSubscriber, error mapping
Read more
description: "Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API, endpoint, controller, response, error handling, JSON, REST, API response, exception subscriber, HTTP"
Symfony API Response Standard
You are an expert in building standardized REST APIs within Symfony hexagonal architecture.
When to Activate
- User creates API endpoints or controllers
- User asks about response format or error handling
- User needs exception handling for APIs
- User mentions REST, JSON, or API design
Standard JSON Payload
ALL API responses use this format:
{
"result": null,
"error": null,
"extra": null,
"status": 200
}| Field | Type | Description | |-------|------|-------------| | `result` | `mixed` | Success data (null on error) | | `error` | `?object` | Error details (null on success) | | `extra` | `?object` | Metadata: pagination, debug info | | `status` | `int` | HTTP status code |
Success Response
{
"result": {"id": "uuid-123", "name": "John"},
"error": null,
"extra": null,
"status": 200
}Error Response
{
"result": null,
"error": {"code": "USER_NOT_FOUND", "message": "User not found"},
"extra": null,
"status": 404
}Debug Mode (APP_DEBUG=true)
{
"result": null,
"error": {"code": "INTERNAL_ERROR", "message": "Something went wrong"},
"extra": {"debug": {"exception": "...", "trace": "..."}},
"status": 500
}Controller Pattern
Controllers are thin — dispatch to buses only:
namespace App\Presentation\{Module}\API;
use App\Presentation\Shared\ApiResponseTrait;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
#[Route('/api/{module}')]
final class {Entity}Controller
{
use ApiResponseTrait;
public function __construct(
private readonly MessageBusInterface $commandBus,
private readonly MessageBusInterface $queryBus,
) {
}
#[Route('', methods: ['POST'])]
#[IsGranted('ROLE_...')] // ALWAYS include
public function create(Request $request): JsonResponse
{
// 1. Parse input
// 2. Create command
// 3. Dispatch to command bus
// 4. Return success response
}
}References
See `references/` for detailed guides:
- `payload-schema.md` — ApiResponseTrait, response helpers
- `exception-handling.md` — ExceptionSubscriber, error mapping
A Claude Code plugin that enforces hexagonal architecture (ports & adapters) in Symfony projects. Works with both new projects (full scaffolding) and existing projects (progressive, module-by-module refactoring).
Other skills on symfony-hexagonal-skill.
- /symfony-cqrs-handlers
Symfony CQRS command/query handlers — commands, queries, handlers, bus configuration, use cases. Triggers on: command, query, handler, CQRS, bus, use case, command handler, query handler, message bus
Open skill - /symfony-doctrine-persistence
Symfony Doctrine persistence — repository adapters, entity mapping, migrations, transactions, database patterns. Triggers on: doctrine, repository, persistence, database, mapping, migration, ORM, entity manager, DBAL, transaction
Open skill - /symfony-domain-modeling
Symfony domain modeling — entities, value objects, domain events, aggregates, domain exceptions. Triggers on: entity, value object, domain event, aggregate, domain exception, domain model, domain logic, business rule, invariant
Open skill - /symfony-hexagonal-architecture
Symfony hexagonal architecture setup — project structure, module scaffolding, layer responsibilities, dependency rules. Triggers on: architecture, module, layer, hexagonal, scaffold, project structure, directory structure, new project, new module
Open skill - /symfony-messenger-async
Symfony Messenger async processing — message queues, retry strategies, failure transport, Symfony Scheduler, idempotency patterns, background jobs. Triggers on: messenger, async, queue, retry, scheduler, background job, worker, transport, message queue, cron, scheduled task
Open skill - /symfony-ports-adapters
Symfony ports and adapters — port interfaces, adapter implementations, dependency injection, autowiring, repository interfaces. Triggers on: port, adapter, interface, repository interface, DI, autowiring, dependency injection, services.yaml, binding
Open skill

