{"id":16538264,"url":"https://github.com/thewunder/corma","last_synced_at":"2025-08-08T12:14:02.529Z","repository":{"id":56352646,"uuid":"52828044","full_name":"thewunder/corma","owner":"thewunder","description":"Convention-based Object-Relational Mapper","archived":false,"fork":false,"pushed_at":"2025-01-23T20:48:29.000Z","size":775,"stargazers_count":32,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T06:03:03.116Z","etag":null,"topics":["database","orm","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thewunder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-29T22:01:35.000Z","updated_at":"2025-01-23T20:48:33.000Z","dependencies_parsed_at":"2024-03-25T15:24:34.964Z","dependency_job_id":"8e6d6a0c-7241-45a9-aa00-9dc9e3b4df9d","html_url":"https://github.com/thewunder/corma","commit_stats":{"total_commits":511,"total_committers":6,"mean_commits":85.16666666666667,"dds":0.2093933463796478,"last_synced_commit":"2909acf4a4978a7d493cf4fe2721b12d51b9bcd0"},"previous_names":[],"tags_count":82,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewunder%2Fcorma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewunder%2Fcorma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewunder%2Fcorma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewunder%2Fcorma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thewunder","download_url":"https://codeload.github.com/thewunder/corma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247608153,"owners_count":20965952,"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","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":["database","orm","php"],"created_at":"2024-10-11T18:44:53.805Z","updated_at":"2025-04-07T07:11:47.780Z","avatar_url":"https://github.com/thewunder.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Corma\n=====\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.txt)\n\nCorma is a high-performance, convention-based ORM based on Doctrine DBAL.\n\nCorma is great because:\n\n* No complex and difficult to verify annotations or configuration files\n* Promotes consistent code organization\n* Loads and saves one-to-one, one-to-many, many-to-many, and polymorphic relationships\n* Can save multiple objects in a single query (using an upsert)\n* Makes it easy to cache and avoid database queries\n* Supports soft deletes\n* Makes it easy to handle transactions in a Unit of Work\n* Highly customizable\n\nCorma doesn't:\n\n* Autoload or lazy load relationships by default\n* Do migrations or code generation\n\nWorks in MySql and PostgreSQL.\n\nInstall via Composer\n--------------------\n\nVia the command line:\n\n    composer.phar require thewunder/corma ^5.0\n\nOr add the following to the require section your composer.json:\n\n    \"thewunder/corma\": \"^5.0\"\n\nFor PHP versions \u003c 8.1 use Corma version ~3.0 \n\nBasic Usage\n-----------\nCreate a DataObject\n\n```php\nnamespace YourNamespace\\Dataobjects;\n\nuse Corma\\Relationship\\ManyToMany;\nuse Corma\\Relationship\\OneToMany;\nuse Corma\\Relationship\\OneToOne;\n\nclass YourDataObject {\n    protected $id;\n\n    //If the property name == column name on the table your_data_objects it will be saved\n    protected $myColumn;\n\n    protected ?int $otherObjectId = null;\n    \n    #[OneToOne]\n    protected ?OtherObject $otherObject = null;\n    \n    #[OneToMany(AnotherObject::class)]\n    protected ?array $anotherObjects = null;\n    \n    #[ManyToMany(DifferentObject::class, 'your_data_object_different_link_table')]\n    protected ?array $differentObjects = null;\n    //Getters and setters..\n}\n```\n\nAnd a Repository (optional)\n```php\nnamespace YourNamespace\\Dataobjects\\Repository;\n\nclass YourDataObjectRepository extends ObjectRepository {\n    //Override default behavior and add custom methods...\n}\n```\n\nCreate the orm and use it\n```php\n$db = DriverManager::getConnection(...); //see Doctrine DBAL docs\n$orm = ObjectMapper::withDefaults($db, $container); //uses any PSR-11 compatible DI container\n\n$object = $orm-\u003ecreate(YourDataObject::class);\n//Call setters...\n$orm-\u003esave($object);\n//Call more setters...\n$orm-\u003esave($object);\n\n//Call more setters on $object...\n$objects = [$object];\n$newObject = $orm-\u003ecreate(YourDataObject::class);\n//call setters on $newObject...\n$objects[] = $newObject;\n\n$orm-\u003esaveAll($objects);\n\n//find existing object by id\n$existingObject = $orm-\u003efind(YourDataObject::class, 5);\n\n//find existing objects with myColumn \u003e= 42 AND otherColumn = 1\n$existingObjects = $orm-\u003efindBy(YourDataObject::class, ['myColumn \u003e='=\u003e42, 'otherColumn'=\u003e1], ['sortColumn'=\u003e'ASC']);\n\n//load relationships\n$orm-\u003eload($existingObjects, 'otherObject');\n$orm-\u003eload($existingObjects, 'anotherObjects');\n$orm-\u003eload($existingObjects, 'differentObjects');\n\n//delete those\n$orm-\u003edeleteAll($existingObjects);\n```\n\nDocumentation\n-------------\n\nSee [the wiki](https://github.com/thewunder/corma/wiki) for full documentation.\n\nContributing\n------------\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n\n[ico-version]: https://img.shields.io/packagist/v/thewunder/corma.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[link-packagist]: https://packagist.org/packages/thewunder/corma\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewunder%2Fcorma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthewunder%2Fcorma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewunder%2Fcorma/lists"}