{"id":24767119,"url":"https://github.com/leven-framework/orm","last_synced_at":"2025-09-10T10:39:02.887Z","repository":{"id":43997884,"uuid":"442421947","full_name":"leven-framework/orm","owner":"leven-framework","description":"🗂️ map pure PHP objects to a database; configure entities with PHP8 attributes, intuitive relationship mapping","archived":false,"fork":false,"pushed_at":"2022-07-13T13:43:32.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-23T23:37:58.679Z","etag":null,"topics":["abstraction","database","mapper","mapping","object-relational-mapper","orm","php","php-attributes","php8","relations"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leven-framework.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-28T10:02:25.000Z","updated_at":"2022-07-14T08:41:45.000Z","dependencies_parsed_at":"2022-07-11T00:46:30.170Z","dependency_job_id":null,"html_url":"https://github.com/leven-framework/orm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/leven-framework/orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leven-framework%2Form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leven-framework%2Form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leven-framework%2Form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leven-framework%2Form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leven-framework","download_url":"https://codeload.github.com/leven-framework/orm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leven-framework%2Form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274447765,"owners_count":25287114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstraction","database","mapper","mapping","object-relational-mapper","orm","php","php-attributes","php8","relations"],"created_at":"2025-01-29T00:52:19.813Z","updated_at":"2025-09-10T10:39:02.839Z","avatar_url":"https://github.com/leven-framework.png","language":"PHP","readme":"# Leven ORM\n\n## Features\n- 💾 easily map pure PHP objects to a database\n- ⛓ intuitive relationship mapping\n- 🔧 configure entities with PHP8 attributes\n- 🧪 easily testable with a mock database - uses [Leven Database Adapter](https://github.com/leven-framework/dba-common)\n- 🔤 automatic table and column name mapping\n- 🐌 automatic eager loading and caching\n- 🔝 support for auto-incrementing primary props\n- 📁 all props are stored JSON-encoded in a single column\n\n## Example\n\n```php\nrequire 'vendor/autoload.php';\n\n$repo = new \\Leven\\ORM\\Repository(\n    new \\Leven\\DBA\\MySQL\\MySQLAdapter(\n        database: 'example',\n        user: 'username',\n        password: 'password',\n    )\n);\n\n(new \\Leven\\ORM\\RepositoryConfigurator($repo))\n    -\u003escanEntityClasses();\n\nclass Author extends \\Leven\\ORM\\Entity {\n    #[\\Leven\\ORM\\Attribute\\PropConfig(primary: true)]\n    public int $id;\n    \n    public function __construct(\n        public string $name;\n    ){}\n}\n\nclass Book extends \\Leven\\ORM\\Entity {\n    #[\\Leven\\ORM\\Attribute\\PropConfig(primary: true)]\n    public int $id;\n    \n    public function __construct(\n        // this defines that each Book must belong to an Author\n        public Author $author;\n        \n        // we can provide rules for the Book's title\n        #[\\Leven\\ORM\\Attribute\\ValidationConfig(notEmpty: true, maxLength: 256)]\n        public string $title;\n        \n        // store this prop in a separate column, so we can search for entities by it\n        #[\\Leven\\ORM\\Attribute\\PropConfig(index: true)]\n        public string $isbn;\n        \n        // when storing or reading to the db, we'll use a converter to convert this prop to/from a scalar value\n        #[\\Leven\\ORM\\Attribute\\PropConfig(converter: \\Leven\\ORM\\Converter\\DateTimeStringConverter::class)]\n        public DateTime $releaseDate;\n    ){}\n}\n\n$john = new Author('John Doe');\n$example = new Book($author, 'Example Book', '123456789', new DateTime('2021-01-01'));\n$repo-\u003estore($john, $example);\n\n// later...\n\n$author = $repo-\u003eget(Author::class, 1); // get author with id 1\n$books = $repo-\u003efindChildrenOf($author, Book::class)-\u003eget();\n\n$book = $repo-\u003efind(Book::class)-\u003ewhere('isbn', '123456789')-\u003egetFirst();\n$book-\u003etitle = 'New Title';\n$repo-\u003eupdate($book);\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleven-framework%2Form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleven-framework%2Form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleven-framework%2Form/lists"}