From 3724255e709298b549d836941f67579c22130454 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Sun, 23 Nov 2025 23:42:23 +0900 Subject: [PATCH] Improve README quick start example with Entity definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The opening example now: - Includes User class definition (previously missing) - Uses UserQueryInterface naming (aligns with MediaQuery project name) - Uses item() method (consistent with demo/tests codebase) - Uses user_item.sql filename (follows existing conventions) - Shows actual usage in step 3 (previously just commented) This makes the 1-2-3 flow complete and self-contained for beginners. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3e6078d..ac6061d 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,28 @@ Traditional ORMs try to hide SQL behind object abstractions. Ray.MediaQuery takes a different approach: ```php -// 1. Define your interface -interface UserRepository +// 1. Define your interface (and Entity) +interface UserQueryInterface { - #[DbQuery('user_by_id')] - public function find(string $id): User; + #[DbQuery('user_item')] + public function item(string $id): ?User; +} + +class User +{ + public function __construct( + public readonly string $id, + public readonly string $name + ) {} } // 2. Write your SQL --- user_by_id.sql -SELECT * FROM users WHERE id = :id +-- user_item.sql +SELECT id, name FROM users WHERE id = :id -// 3. That's it. No implementation needed. -// find($id) → binds to user_by_id.sql → executes → returns User object +// 3. Use it (no implementation needed!) +$userQuery = $injector->getInstance(UserQueryInterface::class); +$user = $userQuery->item('user-123'); ``` ## Why Ray.MediaQuery?