
Symfony:interfaces And Autowiring Skill
- 575 installs
- 190 repo stars
- Updated August 6, 2026
- makfly/superpowers-symfony
symfony:interfaces-and-autowiring is a Claude Code skill that generates clean PHP interfaces and Symfony autowiring configurations following Symfony dependency-injection best practices for backend developers.
About
symfony:interfaces-and-autowiring is a Claude Code skill from makfly/superpowers-symfony ranked 2 on skills.sh with 469 installs. It guides agents to produce PHP service interfaces and Symfony autowiring definitions that follow framework conventions for dependency injection, service tagging, and constructor binding. Developers reach for symfony:interfaces-and-autowiring when refactoring concrete classes into testable contracts or fixing misconfigured services.yaml entries in Symfony 6/7 projects. The skill targets backend engineers maintaining hexagonal or service-oriented PHP architectures who want AI assistance aligned with Symfony container rules rather than generic OOP snippets. It is the second-ranked skill in its catalog, reflecting strong adoption for DI scaffolding tasks.
- Generates strict, typed interfaces for services and repositories
- Produces autowiring-compatible service definitions and YAML configs
- Enforces dependency injection patterns that reduce coupling
- Creates ready-to-use trait and contract files for Symfony projects
- Outputs implementation stubs that pass static analysis
Symfony:Interfaces And Autowiring by the numbers
- 575 all-time installs (skills.sh)
- Ranked #730 of 4,492 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 11, 2026 (Skillselion catalog sync)
npx skills add https://github.com/makfly/superpowers-symfony --skill symfonyinterfaces-and-autowiringAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 575 |
|---|---|
| repo stars | ★ 190 |
| Last updated | August 6, 2026 |
| Repository | makfly/superpowers-symfony ↗ |
How do you scaffold Symfony interfaces and autowiring config?
Generate clean PHP interfaces and autowiring configurations that follow Symfony best practices.
Who is it for?
Symfony PHP developers refactoring services into interfaces or fixing dependency-injection configuration with AI guidance matched to framework conventions.
Skip if: Non-Symfony PHP projects, frontend-only work, or teams that already use a fully generated DI schema with no interface gaps.
When should I use this skill?
User asks to create Symfony service interfaces, configure autowiring, or refactor PHP classes for dependency injection in a Symfony project
What you get
PHP service interfaces, services.yaml autowiring definitions, and constructor-injection bindings aligned with Symfony conventions
- PHP service interfaces
- services.yaml autowiring config
By the numbers
- 469 installs on skills.sh
- Ranked 2 in makfly/superpowers-symfony catalog
Files
Interfaces And Autowiring (Symfony)
Use when
- Refining architecture/workflows/context handling in Symfony projects.
- Planning and executing medium/complex changes safely.
Default workflow
1. Establish current boundaries, constraints, and coupling points. 2. Propose smallest coherent architectural adjustment. 2. Execute in checkpoints with validation at each stage. 2. Summarize tradeoffs and follow-up backlog.
Guardrails
- Use existing project patterns by default.
- Avoid broad refactors without explicit need.
- Keep decision log clear and auditable.
Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.
Output contract
- Architecture/workflow changes.
- Checkpoint validation outcomes.
- Residual risks and next steps.
References
reference.mddocs/complexity-tiers.md
Reference
Interfaces and Autowiring in Symfony
Basic Autowiring
Symfony automatically injects dependencies based on type-hints:
<?php
// src/Service/OrderService.php
namespace App\Service;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
class OrderService
{
public function __construct(
private EntityManagerInterface $em,
private LoggerInterface $logger,
) {}
public function createOrder(array $data): Order
{
$this->logger->info('Creating order', $data);
// ...
}
}No configuration needed - Symfony wires it automatically.
Interface Binding
Define Interface
<?php
// src/Service/PaymentGatewayInterface.php
namespace App\Service;
interface PaymentGatewayInterface
{
public function charge(int $amount, string $currency): PaymentResult;
public function refund(string $transactionId, int $amount): RefundResult;
}Implementation
<?php
// src/Service/StripePaymentGateway.php
namespace App\Service;
class StripePaymentGateway implements PaymentGatewayInterface
{
public function __construct(
private string $apiKey,
) {}
public function charge(int $amount, string $currency): PaymentResult
{
// Stripe implementation
}
public function refund(string $transactionId, int $amount): RefundResult
{
// Stripe implementation
}
}Bind Interface to Implementation
# config/services.yaml
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
# Bind interface to implementation
App\Service\PaymentGatewayInterface: '@App\Service\StripePaymentGateway'
# Or with parameters
App\Service\StripePaymentGateway:
arguments:
$apiKey: '%env(STRIPE_API_KEY)%'Use in Services
class OrderService
{
public function __construct(
private PaymentGatewayInterface $paymentGateway, // Autowired!
) {}
}Service Decoration
Wrap a service to add behavior without modifying it:
<?php
// src/Service/LoggingPaymentGateway.php
namespace App\Service;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
#[AsDecorator(decorates: StripePaymentGateway::class)]
class LoggingPaymentGateway implements PaymentGatewayInterface
{
public function __construct(
#[AutowireDecorated]
private PaymentGatewayInterface $inner,
private LoggerInterface $logger,
) {}
public function charge(int $amount, string $currency): PaymentResult
{
$this->logger->info('Charging payment', [
'amount' => $amount,
'currency' => $currency,
]);
$result = $this->inner->charge($amount, $currency);
$this->logger->info('Payment result', [
'success' => $result->isSuccessful(),
'transactionId' => $result->getTransactionId(),
]);
return $result;
}
public function refund(string $transactionId, int $amount): RefundResult
{
$this->logger->info('Processing refund', [
'transactionId' => $transactionId,
'amount' => $amount,
]);
return $this->inner->refund($transactionId, $amount);
}
}Tagged Services
Define Tag
<?php
// src/Export/ExporterInterface.php
namespace App\Export;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('app.exporter')]
interface ExporterInterface
{
public function supports(string $format): bool;
public function export(array $data): string;
}Implementations
<?php
// src/Export/CsvExporter.php
namespace App\Export;
class CsvExporter implements ExporterInterface
{
public function supports(string $format): bool
{
return $format === 'csv';
}
public function export(array $data): string
{
// CSV export logic
}
}
// src/Export/JsonExporter.php
class JsonExporter implements ExporterInterface
{
public function supports(string $format): bool
{
return $format === 'json';
}
public function export(array $data): string
{
return json_encode($data, JSON_PRETTY_PRINT);
}
}Inject All Tagged Services
<?php
// src/Service/ExportService.php
namespace App\Service;
use App\Export\ExporterInterface;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
class ExportService
{
/**
* @param iterable<ExporterInterface> $exporters
*/
public function __construct(
#[AutowireIterator('app.exporter')]
private iterable $exporters,
) {}
public function export(array $data, string $format): string
{
foreach ($this->exporters as $exporter) {
if ($exporter->supports($format)) {
return $exporter->export($data);
}
}
throw new \InvalidArgumentException("Unsupported format: {$format}");
}
public function getSupportedFormats(): array
{
$formats = [];
foreach ($this->exporters as $exporter) {
// Each exporter reports what it supports
}
return $formats;
}
}Named Autowiring
When you have multiple implementations:
# config/services.yaml
services:
App\Service\StripePaymentGateway:
arguments:
$apiKey: '%env(STRIPE_API_KEY)%'
App\Service\PaypalPaymentGateway:
arguments:
$clientId: '%env(PAYPAL_CLIENT_ID)%'
# Named bindings
App\Service\PaymentGatewayInterface $stripeGateway: '@App\Service\StripePaymentGateway'
App\Service\PaymentGatewayInterface $paypalGateway: '@App\Service\PaypalPaymentGateway'class PaymentService
{
public function __construct(
private PaymentGatewayInterface $stripeGateway, // Stripe
private PaymentGatewayInterface $paypalGateway, // PayPal
) {}
}Lazy Services
Load service only when actually used:
use Symfony\Component\DependencyInjection\Attribute\Lazy;
#[Lazy]
class ExpensiveService
{
public function __construct()
{
// Heavy initialization
}
}Debug Commands
# List all services
bin/console debug:container
# Find specific service
bin/console debug:container OrderService
# Show autowiring candidates
bin/console debug:autowiring
# Show autowiring for specific type
bin/console debug:autowiring PaymentBest Practices
1. Program to interfaces: Depend on interfaces, not implementations 2. Constructor injection: Always use constructor injection 3. Final classes: Make services final by default 4. Readonly properties: Use private readonly for dependencies 5. Minimal interfaces: Keep interfaces focused (ISP) 6. Decorate, don't modify: Use decoration for cross-cutting concerns
Skill Operating Checklist
Design checklist
- Confirm operation boundaries and invariants first.
- Minimize scope while preserving contract correctness.
- Test both happy path and negative path behavior.
Validation commands
- rg --files
- composer validate
- ./vendor/bin/phpstan analyse
Failure modes to test
- Invalid payload or forbidden actor.
- Boundary values / not-found cases.
- Retry or partial-failure behavior for async flows.
Related skills
How it compares
Use symfony:interfaces-and-autowiring for Symfony-specific DI and interface scaffolding rather than generic PHP class generation skills.
FAQ
What Symfony artifacts does symfony:interfaces-and-autowiring produce?
symfony:interfaces-and-autowiring produces PHP service interface definitions and Symfony services.yaml autowiring configuration entries. Output follows Symfony dependency-injection conventions including constructor binding and service tagging patterns.
How popular is symfony:interfaces-and-autowiring on skills.sh?
symfony:interfaces-and-autowiring from makfly/superpowers-symfony ranks 2 in its catalog with 469 installs on skills.sh. Backend developers use it for AI-guided Symfony interface and autowiring scaffolding.