Skip to content
Development
Skill

/doctrine-events

React to Doctrine entity lifecycle in Symfony with attribute listeners (#[AsDoctrineListener]/#[AsEntityListener], ORM 3) and lifecycle callbacks

From plugin
superpowers-symfony
23344 skills14 agents13 commands1 hook

Claude Code

$ npx -y skills add dev-toolings/superpowers-symfony --skill doctrine-events --agent claude-code

SKILL.md

doctrine-events.SKILL.md
name: doctrine-events
description: React to Doctrine entity lifecycle in Symfony with attribute listeners (#[AsDoctrineListener]/#[AsEntityListener], ORM 3) and lifecycle callbacks
capabilities: [read, search, edit, shell]
tags: [doctrine]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash

Doctrine Events (Symfony)

Use when

  • You need side effects on entity persistence (timestamps, slugs, search indexing, notifications).
  • Migrating an `EventSubscriberInterface` Doctrine subscriber to ORM 3.
  • Choosing between lifecycle callbacks, entity listeners, and global lifecycle listeners.

Default workflow

1. Pick the narrowest mechanism: callback (one entity, no deps) → entity listener (one entity, needs services) → lifecycle listener (cross-cutting, all entities). 2. Wire it with attributes (`#[ORM\HasLifecycleCallbacks]`, `#[AsEntityListener]`, `#[AsDoctrineListener]`). 3. Type the event argument by its per-event class (`PostPersistEventArgs`, `PreUpdateEventArgs`, …). 4. Verify the side effect fires with a targeted functional test against a real DB.

Guardrails

  • ORM 3.0 removed `EventSubscriberInterface` Doctrine subscribers — never reintroduce them.
  • Type-check the entity early in a global lifecycle listener (it fires for every entity).
  • Never call `flush()` inside a Doctrine event handler — it corrupts the in-flight unit of work.
  • `preUpdate` is restricted: change fields only via `$args->setNewValue()`, never touch associations.

Progressive disclosure

  • Use this file for execution posture and risk controls.
  • Open `reference.md` for the three mechanisms, the event-args matrix, and migration from subscribers.

Output contract

  • Listener/callback class with the correct attribute.
  • Justification for the chosen mechanism.
  • Validation outcomes (test that the side effect fired).

References

  • `reference.md`
Read more
@dev-toolings
Ships withsuperpowers-symfony

Superpowers Symfony gives coding agents deep, version-accurate Symfony expertise: from Doctrine schema design and API Platform REST/GraphQL APIs to test-driven development, async Messenger workflows, caching, rate limiting, and clean architecture.

23344 skills14 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
233
Star history of dev-toolings/superpowers-symfony on GitHub, a chart by star-history.com

Other skills on superpowers-symfony.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react5d252k
@facebook@facebookInstall Skill

Questions about doctrine-events.

Which coding agents can use doctrine-events?
doctrine-events installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.