/symfony-skills:bundle-organizationfrom symfony-skills
Guides structuring a Symfony 7 project's src/ directory by feature/module, configuring services with autowiring, and organizing config/ conventions for a modular monolith layout.
Ships in symfony-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Since Symfony 4, application code lives in src/ under the App\ namespace — not in a custom bundle. Create a bundle only for reusable library code shared across projects. For an application, organize src/ by feature/module, not by technical type.
src/
├── Kernel.php
├── Sales/ # bounded context / module
│ ├── Domain/
│ ├── Application/
│ ├── Infrastructure/
│ └── UI/ # controllers, console commands, CLI
├── Billing/
│ └── ...
└── Shared/ # cross-cutting kernel: base value objects, bus, ids
config/
├── packages/ # per-bundle config (doctrine.yaml, security.yaml, ...)
│ └── prod/ · dev/ · test/ # env overrides
├── routes/ # route imports
├── services.yaml # app service wiring
└── bundles.php # registered bundles
src/
├── Controller/ # ❌ for a large app, everything-in-one-folder doesn't scale
├── Entity/
├── Repository/
└── Service/
This is fine for a tiny app, but in a domain of any size it scatters one feature across five folders. Group by module first, then layer inside.
Rely on Symfony's defaults — autowiring + autoconfiguration + resource autodiscovery:
# config/services.yaml
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/'
exclude:
- '../src/Kernel.php'
- '../src/**/Domain/**/{Entity,ValueObject}' # plain objects, not services
App\Sales\Domain\OrderRepository: '@App\Sales\Infrastructure\Doctrine\DoctrineOrderRepository'
#[Autowire] at the point of use — don't sprinkle %env()% reads:public function __construct(
#[Autowire('%env(int:ORDER_TTL_SECONDS)%')] private readonly int $orderTtl,
#[Autowire(service: 'app.payment.http_client')] private readonly HttpClientInterface $client,
) {}
#[AutowireIterator] / #[TaggedIterator] for strategy sets:public function __construct(
#[AutowireIterator('app.payment_gateway')] private readonly iterable $gateways,
) {}
| Class | Location |
|---|---|
| Doctrine entity / aggregate | src/<Module>/Domain/ (or Domain/Model/) |
| Repository interface (port) | src/<Module>/Domain/ |
| Repository Doctrine impl | src/<Module>/Infrastructure/Doctrine/ |
| Application service / handler | src/<Module>/Application/ |
| Controller | src/<Module>/UI/Http/ (or top-level Controller/ in small apps) |
| Console command | src/<Module>/UI/Cli/ |
| DTO (request/response) | src/<Module>/UI/Http/Dto/ |
| Value object | src/<Module>/Domain/ |
| Custom Doctrine type | src/Shared/Infrastructure/Doctrine/Type/ |
secrets:set) or .env.local — never commit real secrets.%env(int:…)%, %env(bool:…)%, %env(json:…)%.$_ENV / getenv() in app code — inject the value.Only for shareable libraries. Modern bundles use AbstractBundle:
final class AcmePaymentBundle extends AbstractBundle
{
public function configure(DefinitionConfigurator $definition): void { /* config tree */ }
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->import('../config/services.yaml');
}
}
AppBundle for application code — modern apps use src/ under App\, no app bundle.Controller/, Entity/, Service/ for a large domain — organize by module first.services.yaml — rely on autowiring + autodiscovery; configure only the exceptions.getenv() / reads $_ENV inside a service — inject the value via #[Autowire('%env(...)%')].Domain plain objects from autoregistration..env — use the secrets vault or .env.local.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub fatonh/symfony-skills --plugin symfony-skills17 skills in this plugin
/api-platform-resourcesUse when exposing data through API Platform 4 — defining #[ApiResource], operations, DTO resources, state providers/processors, serialization groups, filters, and pagination. Use when the task mentions API Platform, ApiResource, state processor, or exposing an entity as a REST/GraphQL endpoint.
/console-commandsUse when creating or refactoring Symfony console commands — never extends Command. On Symfony 8.1+ put #[AsCommand] on a method of a service class (even for a single command); on 7.x use the invokable attribute class. Also covers typed CLI inputs via value resolvers and #[MapInput] DTOs. Use when the task mentions console command, #[AsCommand], bin/console, #[Argument], #[Option], or a CLI task.
/doctrine-migrationsUse when changing the database schema in Symfony — generating Doctrine migrations, writing reversible up()/down(), data migrations, and deploy-safe (zero-downtime) changes. Use when the task mentions migration, schema change, ALTER TABLE, or doctrine:migrations.
/doctrine-ormUse when creating Doctrine ORM 3 entities, associations, repositories, enums, or UUID identifiers in Symfony. Defines entity conventions, attribute mapping, fetch strategy, and repository structure. Use when the task mentions entity, Doctrine, repository, association, or mapping.
/doctrine-query-optimizationUse when writing Doctrine queries, fixing N+1 problems, paginating large result sets, building read models, or tuning DQL/query builder performance. Use when the task mentions N+1, slow query, pagination, DQL, hydration, or read model.
/domain-driven-designUse when modeling a domain in Symfony — aggregates, entities, value objects, domain events, repositories, and the ubiquitous language. Use when the task mentions DDD, aggregate, value object, domain event, or invariant.
Other plugins' skills for the same job