ใช้ทำอะไรได้
ยังไม่มีคำอธิบายภาษาไทย ดูข้อเท็จจริงด้านล่าง หรือเปิดคำอธิบายต้นฉบับจากผู้ทำ
- ต่อแบบ ไฟล์คำสั่งให้ AI อ่าน
- บัญชีหรือคีย์ ยังยืนยันไม่ได้ (ยังไม่ได้อ่าน README)
- หมวด อื่น ๆ
คำอธิบายต้นฉบับจากผู้ทำ (อังกฤษ)
The Official PHP MongoDB ORM/ODMสำหรับผู้ทำ: ติดป้ายใน README
ถ้าคุณเป็นผู้ทำตัวนี้ คัดลอกโค้ดนี้ไปวางใน README ได้เลย ป้ายลิงก์กลับมาที่หน้านี้
[](https://mcp.popnx.com/th/skills/doctrine-mongodb-odm)Skill ที่ทำงานคล้ายกัน
หมวดงานเดียวกัน เรียงแบบเดียวกับหน้ารายการ Skill
| ตัวนี้ mongodb-odm | llmfit | claude-video | VideoCaptioner | claude-cookbooks | |
|---|---|---|---|---|---|
| ผู้ทำ | doctrine | AlexsJones | bradautomates | WEIFENG2333 | anthropics |
| จำนวน Skill | 1 | 1 | 1 | 1 | 4 |
| ดาว GitHub | 1,098 | 39,036 | 21,085 | 16,557 | 54,799 |
| แก้โค้ดล่าสุด | 13 พ.ย. 2569 | 16 พ.ย. 2569 | 25 ก.ย. 2569 | 12 ก.ย. 2569 | 5 พ.ย. 2569 |
| สัญญาอนุญาต | MIT | MIT | MIT | GPL-3.0 | MIT |
ชุดคำสั่ง (Skill) 1 ชุดจาก doctrine ให้ AI อ่านแล้วทำงานตามวิธีนี้ · ไม่ใช่ MCP server
Skill ต่างจาก MCP ยังไง
MCP = มือ
ต่อ AI เข้ากับบริการหรือข้อมูลข้างนอก เช่น อ่าน Notion หรือสร้างใบแจ้งหนี้ ต้องมีโปรแกรมหรือ server ทำงานอยู่
Skill = คู่มือ
ไฟล์ข้อความที่สอน AI ว่างานนี้ทำยังไง ไม่ต่อบริการใด
บางตัวคล้ายกัน: Skill บางตัวมีสคริปต์เรียกเครื่องมือ และ MCP บางตัวส่งแค่ความรู้ ให้ดูที่งานที่อยากทำเป็นหลัก
ใช้กับแอปไหน
ผู้ทำไม่ได้ระบุ · Skill แบบ SKILL.md ใช้ได้กับแอปที่รองรับ Agent Skills เช่น Claude Code, Codex และ Cursor
ติดตั้ง
ปลอดภัยไหม
- ใครทำ
บัญชี GitHub doctrine (องค์กร) เปิดมา 16 ปี
- คนใช้และการดูแล
★ 1,098 ดาว · แก้โค้ดล่าสุด 13 พ.ย. 2569
- มีสคริปต์ไหม
ไม่มี เป็นไฟล์ข้อความล้วน AI อ่านแล้วทำตาม
- ใช้อินเทอร์เน็ตไหม
ไม่มีสคริปต์ จึงไม่เรียกอินเทอร์เน็ตเอง
- แก้ค่าตั้งทั้งเครื่องไหม
ไม่พบ hook หรือการเขียนค่าตั้งของเครื่อง
ตรวจอัตโนมัติจากไฟล์ใน repo ที่ commit 97711ab (อ่านไฟล์อย่างเดียว ไม่ได้รัน) ไม่ใช่การรับรองความปลอดภัย อ่านแล้วตัดสินใจเอง
ขั้นแรก: คุณใช้ AI ตัวไหน
เลือกแอปที่ใช้ แล้วหน้านี้จะแสดงเฉพาะวิธีติดตั้งของแอปนั้น
ทางที่ 1อัปโหลดเข้า claude.ai (เว็บและแอป)
อัปโหลดใน claude.ai ไม่ผ่าน เพราะคำอธิบายยาวเกิน 200 ตัวอักษร (904 ตัวอักษร) ใช้ทาง "ให้ AI ติดตั้งให้" แทน
ทางที่ 1ให้ Claude Code ติดตั้งให้
คัดลอกประโยคนี้ไปวางในแชตของ Claude Code
เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ
AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น
เปิด Claude Code ใหม่ แล้วพิมพ์ /mongodb-odm หรือสั่งงานที่ตรงเรื่อง Claude จะเลือกใช้เอง
ตรวจกับเอกสารทางการล่าสุด 12 พ.ย. 2569 · แหล่ง: code.claude.com
สำหรับคนที่ใช้ Terminal
Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้
เปิด Terminal
Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน
คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.claude/skills
คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md
กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน
เปิด Claude Code ใหม่ แล้วพิมพ์ /mongodb-odm หรือสั่งงานที่ตรงเรื่อง Claude จะเลือกใช้เอง
Skill ที่ติดตั้งเองใช้ได้ในแอป ChatGPT บนคอม, Codex CLI และส่วนขยาย Codex ใน IDE · ChatGPT บนเว็บและมือถือใช้ Skill ที่ติดตั้งเองไม่ได้ ใช้ได้เฉพาะ Skill ที่มากับปลั๊กอินในไดเรกทอรี
แอป ChatGPT บนคอม
แอป ChatGPT บนคอมมี Codex อยู่ในตัว Codex อ่าน Skill จากโฟลเดอร์ ~/.agents/skills
ทางที่ 1ให้ ChatGPT ติดตั้งให้
เปิด Codex ในแอป ChatGPT บนคอม แล้ววางประโยคนี้ในแชต
AI จะบอก path ให้ดูก่อนติดตั้งเสมอ
AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น
ทางที่ 2วางโฟลเดอร์เอง
วางโฟลเดอร์ mongodb-odm ไว้ที่ ~/.agents/skills/mongodb-odm
~ คือโฟลเดอร์บ้านของคุณ ($HOME)
สำหรับคนที่ใช้ Terminal
Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้
เปิด Terminal
Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน
คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.agents/skills
คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md
กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน
หลังติดตั้ง
- แอป ChatGPT บนคอม: เปิด Skills ในแถบข้างเพื่อดูว่า Skill ขึ้นแล้ว
- เรียกใช้: ใน ChatGPT พิมพ์ @ แล้วเลือก Skill · ใน Codex CLI หรือส่วนขยายใน IDE พิมพ์ /skills หรือพิมพ์ $ แล้วตามด้วยชื่อ Skill
- Codex เห็น Skill ที่ติดตั้งใหม่เอง ถ้ายังไม่ขึ้นให้ปิดแล้วเปิด Codex ใหม่
ตรวจกับเอกสารทางการล่าสุด 15 พ.ย. 2569 · แหล่ง: learn.chatgpt.com
ChatGPT บนเว็บและมือถือ
ใช้ Skill ที่ติดตั้งเองไม่ได้ ใช้ได้เฉพาะ Skill ที่มากับปลั๊กอินในไดเรกทอรี
อยากใช้ Skill นี้กับ ChatGPT ให้ใช้แอป ChatGPT บนคอมตามวิธีด้านบน
ตรวจกับเอกสารทางการล่าสุด 15 พ.ย. 2569 · แหล่ง: learn.chatgpt.com
ทางที่ 1ให้ Codex ติดตั้งให้
คัดลอกประโยคนี้ไปวางในแชตของ Codex · ใช้ได้ทั้ง Codex ในแอป ChatGPT บนคอม, Codex CLI และส่วนขยายใน IDE
เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ
AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น
Codex เห็น Skill ที่ติดตั้งใหม่เอง ถ้ายังไม่ขึ้นให้ปิดแล้วเปิด Codex ใหม่ · เรียกใช้: ใน ChatGPT พิมพ์ @ แล้วเลือก Skill · ใน Codex CLI หรือส่วนขยายใน IDE พิมพ์ /skills หรือพิมพ์ $ แล้วตามด้วยชื่อ Skill
ตรวจกับเอกสารทางการล่าสุด 15 พ.ย. 2569 · แหล่ง: learn.chatgpt.com
สำหรับคนที่ใช้ Terminal
Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้
เปิด Terminal
Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน
คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.agents/skills
คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md
กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน
เปิด Codex ใหม่ แล้วสั่งงานที่ตรงเรื่อง Codex จะเห็น skill นี้ในรายการ
ทางที่ 1ให้ Cursor ติดตั้งให้
คัดลอกประโยคนี้ไปวางในแชตของ Cursor
เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ
AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น
ใน Agent chat ของ Cursor พิมพ์ / แล้วเลือก mongodb-odm
ตรวจกับเอกสารทางการล่าสุด 12 พ.ย. 2569 · แหล่ง: cursor.com
สำหรับคนที่ใช้ Terminal
Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้
เปิด Terminal
Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน
คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.cursor/skills
คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md
กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน
ใน Agent chat ของ Cursor พิมพ์ / แล้วเลือก mongodb-odm
ทางที่ 1ให้ AI ติดตั้งให้
สำหรับแอปอื่นที่อ่าน Skill ได้ ประโยคนี้มี path ของ Claude Code, Codex และ Cursor ให้ AI เลือกตามแอปที่ใช้ · คัดลอกประโยคนี้ไปวางในแชตของแอป
เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ
AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น
ตรวจกับเอกสารทางการล่าสุด 12 พ.ย. 2569 · แหล่ง: code.claude.com, learn.chatgpt.com, cursor.com
สำหรับคนที่ใช้ Terminal
แอปอื่นที่รองรับ Agent Skills (เช่น Gemini CLI, GitHub Copilot) เก็บ skill ในโฟลเดอร์ต่างกัน ดูคู่มือของแอปนั้น แล้วคัดลอกโฟลเดอร์ที่มี SKILL.md ไปวาง
ตรวจโฟลเดอร์ skill กับคู่มือทางการของ Claude Code, Codex และ Cursor เมื่อ 11 พ.ย. 2569
ดูไฟล์ต้นฉบับ SKILL.md
ข้อความต่อไปนี้มาจาก repo ของผู้ทำ ไม่ใช่คำสั่งของ PopNx MCP
แสดง 8,000 ตัวอักษรแรก · เปิดไฟล์เต็มบน 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 attribพูดคุย
ถาม แชร์เคล็ดลับ หรือแจ้งว่าใช้ไม่ได้ เรียงตามที่คนกดว่ามีประโยชน์
ยังไม่มีใครโพสต์ ถามหรือแชร์เป็นคนแรกได้เลย
ข้อความในส่วนนี้เขียนโดยผู้ใช้ ไม่ใช่ทีม PopNx
ข้อมูลจาก GitHub
- ดาว GitHub
- 1,098
- ผู้ทำ
- doctrine
- license
- MIT
- แก้โค้ดล่าสุด
- 13 พ.ย. 2569
- ไฟล์ SKILL.md ใน repo (นับรวมสำเนาภาษาอื่นและแม่แบบ)
- 1
- topic
- mongodb, odm, orm, php, symfony