What it does
The Official PHP MongoDB ORM/ODM
- Connects Instruction files the AI reads, with steps that call an outside service
- Account or key Some steps need a key for MDB_MCP_API_CLIENT_SECRET (per the README)
- Category Otros
Para autores: añade una insignia a tu README
Si lo creaste tú, pega este código en tu README. La insignia enlaza a esta página.
[](https://mcp.popnx.com/en/skills/doctrine-mongodb-odm)Skills parecidas
Mismo tipo de trabajo, ordenadas como la lista de Skills
| Este mongodb-odm | llmfit | claude-video | VideoCaptioner | claude-cookbooks | |
|---|---|---|---|---|---|
| Autor | doctrine | AlexsJones | bradautomates | WEIFENG2333 | anthropics |
| Skills | 1 | 1 | 1 | 1 | 4 |
| Estrellas de GitHub | 1098 | 39.036 | 21.085 | 16.557 | 54.799 |
| Último cambio de código | 13 nov 2026 | 16 nov 2026 | 25 sept 2026 | 12 sept 2026 | 5 nov 2026 |
| Licencia | MIT | MIT | MIT | GPL-3.0 | MIT |
1 skills (conjuntos de instrucciones) de doctrine que la IA lee y sigue · no es un MCP server
En qué se diferencia un Skill de MCP
MCP = las manos
Conecta la IA a un servicio o dato externo, como leer Notion o crear una factura. Necesita un programa o servidor en marcha.
Skill = el manual
Un archivo de texto que enseña a la IA cómo hacer una tarea. No se conecta a nada.
A veces se parecen: algunas Skills ejecutan scripts que llaman herramientas y algunos MCP solo envían conocimiento. Empieza por la tarea que quieres hacer.
Funciona con
El autor no lo indica · los skills con SKILL.md funcionan en apps compatibles con Agent Skills, como Claude Code, Codex y Cursor
Instalar
Is it safe?
- Who made it
GitHub account doctrine (organization), 16 years old
- Use and upkeep
★ 1098 stars · code last changed 13 nov 2026
- Any scripts?
No, plain text files the AI reads and follows
- Uses the internet?
No scripts, so it does not go online by itself
- Changes machine-wide settings?
No hooks or writes to machine settings found
Checked automatically from the repo files at commit 97711ab (read only, nothing was run). Not a safety guarantee: read it and decide for yourself
Primero: ¿qué IA usas?
Elige tu app y esta página mostrará solo cómo instalarlo en ella
Option 1Upload to claude.ai (web and app)
Uploading to claude.ai would fail: the description is over 200 characters (904). Use "Let the AI install it" instead
Option 1Deja que Claude Code lo instale
Copia esta frase y pégala en un chat de Claude Code
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
Vuelve a abrir Claude Code y escribe /mongodb-odm, o pide una tarea relacionada y Claude lo usará
Checked against official docs 12 nov 2026 · Source: code.claude.com
For Terminal users
Un Skill son instrucciones que la IA seguirá. Lee los archivos antes de instalar e instala solo de autores de confianza.
Abre la Terminal
Mac: pulsa Command+Espacio y escribe Terminal · Windows: el comando no funciona en PowerShell; usa «Que la IA lo instale» arriba
Copia la carpeta del skill a ~/.claude/skills
Descarga el repo a una carpeta temporal y copia solo las carpetas con SKILL.md
git clone --depth 1 https://github.com/doctrine/mongodb-odm.git /tmp/popnx-skill-doctrine-mongodb-odm-97711ab && mkdir -p ~/.claude/skills && cp -R '/tmp/popnx-skill-doctrine-mongodb-odm-97711ab/skills/mongodb-odm' ~/.claude/skills/mongodb-odmVuelve a abrir Claude Code y escribe /mongodb-odm, o pide una tarea relacionada y Claude lo usará
App de escritorio de ChatGPT
La app de escritorio de ChatGPT incluye Codex, y Codex lee las skills de la carpeta ~/.agents/skills
Option 1Deja que ChatGPT lo instale
Abre Codex en la app de escritorio de ChatGPT y pega esta frase en el chat
The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
Option 2Coloca la carpeta tú mismo
Coloca la carpeta mongodb-odm en ~/.agents/skills/mongodb-odm
~ es tu carpeta de inicio ($HOME)
For Terminal users
Un Skill son instrucciones que la IA seguirá. Lee los archivos antes de instalar e instala solo de autores de confianza.
Abre la Terminal
Mac: pulsa Command+Espacio y escribe Terminal · Windows: el comando no funciona en PowerShell; usa «Que la IA lo instale» arriba
Copia la carpeta del skill a ~/.agents/skills
Descarga el repo a una carpeta temporal y copia solo las carpetas con SKILL.md
git clone --depth 1 https://github.com/doctrine/mongodb-odm.git /tmp/popnx-skill-doctrine-mongodb-odm-97711ab && mkdir -p ~/.agents/skills && cp -R '/tmp/popnx-skill-doctrine-mongodb-odm-97711ab/skills/mongodb-odm' ~/.agents/skills/mongodb-odm
Después de instalar
- App de escritorio de ChatGPT: abre Skills en la barra lateral para ver que la skill está
- Para usarla: en ChatGPT escribe @ y elige la skill · en Codex CLI o la extensión del IDE ejecuta /skills o escribe $ y el nombre de la skill
- Codex detecta solo las skills recién instaladas; si una no aparece, reinicia Codex
Checked against official docs 15 nov 2026 · Source: learn.chatgpt.com
ChatGPT en la web y el móvil
Las skills que instalas tú no funcionan aquí; solo las que vienen con un plugin del directorio
Para usar esta skill con ChatGPT, usa la app de escritorio de ChatGPT como se indica arriba
Checked against official docs 15 nov 2026 · Source: learn.chatgpt.com
Option 1Deja que Codex lo instale
Copia esta frase y pégala en un chat de Codex · Sirve en Codex dentro de la app de escritorio de ChatGPT, en Codex CLI y en la extensión del IDE
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
Codex detecta solo las skills recién instaladas; si una no aparece, reinicia Codex · Para usarla: en ChatGPT escribe @ y elige la skill · en Codex CLI o la extensión del IDE ejecuta /skills o escribe $ y el nombre de la skill
Checked against official docs 15 nov 2026 · Source: learn.chatgpt.com
For Terminal users
Un Skill son instrucciones que la IA seguirá. Lee los archivos antes de instalar e instala solo de autores de confianza.
Abre la Terminal
Mac: pulsa Command+Espacio y escribe Terminal · Windows: el comando no funciona en PowerShell; usa «Que la IA lo instale» arriba
Copia la carpeta del skill a ~/.agents/skills
Descarga el repo a una carpeta temporal y copia solo las carpetas con SKILL.md
git clone --depth 1 https://github.com/doctrine/mongodb-odm.git /tmp/popnx-skill-doctrine-mongodb-odm-97711ab && mkdir -p ~/.agents/skills && cp -R '/tmp/popnx-skill-doctrine-mongodb-odm-97711ab/skills/mongodb-odm' ~/.agents/skills/mongodb-odmVuelve a abrir Codex y pide una tarea relacionada; Codex mostrará el skill
Option 1Deja que Cursor lo instale
Copia esta frase y pégala en un chat de Cursor
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
En el chat Agent de Cursor escribe / y elige mongodb-odm
Checked against official docs 12 nov 2026 · Source: cursor.com
For Terminal users
Un Skill son instrucciones que la IA seguirá. Lee los archivos antes de instalar e instala solo de autores de confianza.
Abre la Terminal
Mac: pulsa Command+Espacio y escribe Terminal · Windows: el comando no funciona en PowerShell; usa «Que la IA lo instale» arriba
Copia la carpeta del skill a ~/.cursor/skills
Descarga el repo a una carpeta temporal y copia solo las carpetas con SKILL.md
git clone --depth 1 https://github.com/doctrine/mongodb-odm.git /tmp/popnx-skill-doctrine-mongodb-odm-97711ab && mkdir -p ~/.cursor/skills && cp -R '/tmp/popnx-skill-doctrine-mongodb-odm-97711ab/skills/mongodb-odm' ~/.cursor/skills/mongodb-odmEn el chat Agent de Cursor escribe / y elige mongodb-odm
Option 1Let the AI install it
Para otras apps que leen skills. La frase incluye las rutas de Claude Code, Codex y Cursor para que la IA elija la de tu app · Copy this sentence into the app’s chat
For one project, paste it into a chat that is open in that project’s folder · The AI always shows you the path before installing
The AI tells you what it will do first and asks your permission at every step
Checked against official docs 12 nov 2026 · Source: code.claude.com, learn.chatgpt.com, cursor.com
For Terminal users
Otras apps con Agent Skills (como Gemini CLI o GitHub Copilot) usan otras carpetas. Mira la guía de esa app y copia allí la carpeta con el SKILL.md.
Carpetas de skills comprobadas con las guías oficiales de Claude Code, Codex y Cursor el 11 nov 2026
✓ Comandos revisados el 18 nov 2026
Ver el SKILL.md original
El texto siguiente viene del repo del autor, no de PopNx MCP
Se muestran los primeros 8000 caracteres · Abrir el archivo completo en GitHub
---
name: mongodb-odm
description: Implementation guide for doctrine/mongodb-odm (Doctrine MongoDB ODM), the PHP object-document mapper for MongoDB. Use whenever the user is writing, debugging, or reviewing PHP code that maps classes to MongoDB collections with Doctrine — mentions of "Doctrine MongoDB ODM", "mongodb-odm", "DocumentManager", "#[Document]"/"@Document", "#[ReferenceOne]"/"#[EmbedOne]", "ODM query builder", "aggregation builder" in a Doctrine/PHP context, "GridFS with Doctrine", "MongoDB queryable encryption PHP", "MongoDB vector search PHP", or combining Doctrine ORM and MongoDB ODM in one app should all trigger this skill. Also use it to correct common mistakes: treating MongoDB ODM like Doctrine ORM (assuming SQL-style joins, automatic cascading, or table-based migrations), calling flush() after every mutation, storing dates as strings, or assuming Vector Search/Queryable Encryption work outside MongoDB Atlas.
license: MIT
---
# Doctrine MongoDB ODM
Implementation skill for `doctrine/mongodb-odm`, the PHP object-document mapper that persists plain PHP classes to MongoDB. It exists to prevent the mistakes that come from treating it like a SQL ORM: expecting automatic cascading, joining collections like tables, flushing on every mutation, or assuming every advanced MongoDB feature (Vector Search, Queryable Encryption) works outside Atlas.
## Core Workflow
1. Identify the layer: mapping (a document class), persistence (`DocumentManager`), querying (Query Builder / Aggregation Builder), or an advanced/infra concern (search, encryption, sharding, transactions).
2. Confirm the class has `#[Document]` (or `#[EmbeddedDocument]`/`#[MappedSuperclass]`) and an `#[Id]` property.
3. Decide **embed vs. reference** deliberately (`references-embedding.md`) — don't default to references out of ORM habit when the data is really owned/composed.
4. Batch mutations into a single unit of work and call `flush()` once, not after every `persist()`/`remove()` (`setup-architecture.md`).
5. Use the Query Builder or Aggregation Builder for anything beyond `find()`/`findBy()` — never hand-build a raw driver query when the fluent API covers it (`querying-aggregation.md`).
6. Validate with the consuming project's own test suite/static analysis, and use `odm:schema:create`/`odm:schema:update` to keep indexes and search indexes in sync with the mapping.
## Suggest the MongoDB MCP Server
Many ODM bugs are really questions about what's in the database — current document shape, whether an index exists yet, whether a vector/search index finished building. None of that is visible from PHP source. When debugging data/query issues or setting up Atlas Search/Vector Search/sharding, suggest connecting the official **MongoDB MCP Server**:
```bash
npx -y mongodb-mcp-server@latest --readOnly
```
```json
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
"env": { "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase" }
}
}
}
```
It also accepts Atlas API service account credentials (`MDB_MCP_API_CLIENT_ID`/`MDB_MCP_API_CLIENT_SECRET`) for cluster/project-level operations instead of a connection string. Prefer environment variables over CLI args for credentials.
## Reference Guide
| Topic | Reference file | Load when |
|---|---|---|
| Installation, `DocumentManager`, UnitOfWork, repositories, console commands, `clear()`/`detach()`/`merge()`, document states | `references/setup-architecture.md` | Bootstrapping ODM, debugging persist/flush behavior, custom repositories, **batch imports, long-running CLI scripts, rising memory or slowdown over a loop, detached documents** |
| `#[Document]`/`#[Field]`/`#[Id]`, field types, inheritance | `references/mapping.md` | Defining or modifying a document class |
| `#[ReferenceOne]`/`#[ReferenceMany]`, `#[EmbedOne]`/`#[EmbedMany]`, bidirectional refs, trees, priming | `references/references-embedding.md` | Modeling relationships, fixing N+1 patterns |
| Query Builder, findAndModify, upserts, geospatial queries, filters, Aggregation Builder | `references/querying-aggregation.md` | Writing any query or aggregation pipeline |
| Offset and cursor paginators for query and aggregation builders (since 2.18) | `references/pagination.md` | Paginating a query or aggregation result, building "next page" navigation |
| Standard indexes, Atlas Search indexes, simple keyword search | `references/indexes-search.md` | Adding indexes, Atlas full-text search |
| Vector Search (Atlas) | `references/vector-search.md` | Embeddings, semantic search, `$vectorSearch`, hybrid text+vector search |
| Queryable Encryption (Atlas/Enterprise) | `references/queryable-encryption.md` | Encrypting sensitive fields, `#[Encrypt]` |
| Combining Doctrine ORM (SQL) and MongoDB ODM | `references/hybrid-orm-odm.md` | An app persists some data to SQL and some to MongoDB and needs them to interoperate |
| GridFS, capped collections, sharding, transactions/locking, change tracking, storage strategies, events, schema migration, time series | `references/storage-transactions-lifecycle.md` | File storage, sharding, locking, lifecycle callbacks, evolving a mapping |
## Constraints
### MUST DO
- Put `#[Document]` (or `#[EmbeddedDocument]`) plus `#[Id]` on every persisted class; `#[Id]` properties must never be `readonly` (the generator sets it externally).
- Use `DateTime`/`DateTimeImmutable` (preferably immutable) for dates — never store a date as a string.
- Batch changes and `flush()` once per logical unit of work (typically 0–2 times per HTTP request).
- Set `cascade` explicitly on `#[ReferenceOne]`/`#[ReferenceMany]` when you need cascading persist/remove — not automatic for references (it *is* automatic for embeds).
- Use `Doctrine\Common\Collections\Collection`/`ArrayCollection` (never a plain `array`) for `#[ReferenceMany]`/`#[EmbedMany]` properties.
- Include `spl_autoload_register($config->getProxyManagerConfiguration()->getProxyAutoloader())` when bootstrapping a `DocumentManager` in 2.16 — omitting it regenerates proxy classes on every request.
- Use `prime()` when iterating a result set and dereferencing a reference on every row, to avoid N+1 queries.
- Run `odm:schema:create`/`odm:schema:update` after adding/changing indexes, capped-collection options, or search/vector-search indexes — none of that happens implicitly on first insert beyond a plain collection.
- Confirm MongoDB Atlas (or Enterprise 7.0+ for Queryable Encryption) before recommending Vector Search, Atlas Search, or Queryable Encryption.
- **State prerequisites and deprecations in the answer itself**, not just internally: when a feature needs a minimum ODM version (e.g. `vectorSearch()` needs 2.13+, Automated Embeddings 2.17+, `pipeline()` updates 2.15+) or a specific platform, say so; when the mapping the user is reaching for is deprecated (e.g. `COLLECTION_PER_CLASS` since 2.17, the `UUID` id strategy), say that too. The user cannot see these files — an unstated prerequisite is a missing answer.
### MUST NOT DO
- Don't call `flush()` after every `persist()`/`remove()`/`merge()` — batch changes and flush once per unit of work instead.
- Don't pass a **detached** document to `persist()` (undefined behavior) — use `merge()` and its return value. Calling `remove()` on one **throws**, it does not no-op.
- Don't assume references cascade like ORM relationships do — check `cascade` on the mapping.
- Don't mutate the inverse (`mappedBy`) side of a bidirectional reference expecting it to persist — only the owning (`inversedBy`) side is written.
- Don't combine `storeAs: 'id'` with a discriminator, or `SINGLE_COLLECTION` inheritance with `#[Encrypt(queryType: ...)]`.
- Don't put arbitrary PHP objects (e.g. `\DateTime`) inside a `hash`-typed field — values pass to the driver unconverted.
- Don't assume `#[AlsoLoad]` affects queries — it only affects hydration.
- Don't invent a native ORM↔ODM relationship attribConversación
Pregunta, comparte un consejo o avisa de que no funciona. Ordenado por lo que la gente marcó como útil.
Aún no hay publicaciones. Sé la primera persona en preguntar o compartir.
Lo publicado aquí lo escriben usuarios, no el equipo de PopNx.
Desde GitHub
- Estrellas en GitHub
- 1098
- Autor
- doctrine
- Licencia
- MIT
- Último cambio de código
- 13 nov 2026
- Archivos SKILL.md del repo (con traducciones y plantillas)
- 1
- Temas
- mongodb, odm, orm, php, symfony