PHPackages                             thewunder/corma - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. thewunder/corma

ActiveLibrary[Database &amp; ORM](/categories/database)

thewunder/corma
===============

Convention-based Alternative ORM

5.2.0(8mo ago)3317.3k↓18.3%4[3 issues](https://github.com/thewunder/corma/issues)1MITPHPPHP &gt;=8.1CI passing

Since Feb 29Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/thewunder/corma)[ Packagist](https://packagist.org/packages/thewunder/corma)[ RSS](/packages/thewunder-corma/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (93)Used By (1)

Corma
=====

[](#corma)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cb0486922974b8fa76cb9a387525a87c0dfc3c6cae96600126b85e3094a6d913/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74686577756e6465722f636f726d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thewunder/corma)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)

Corma is a high-performance, convention-based ORM based on Doctrine DBAL.

Corma is great because:

- No complex and difficult to verify annotations or configuration files
- Promotes consistent code organization
- Loads and saves one-to-one, one-to-many, many-to-many, and polymorphic relationships
- Can save multiple objects in a single query (using an upsert)
- Makes it easy to cache and avoid database queries
- Supports soft deletes
- Makes it easy to handle transactions in a Unit of Work
- Highly customizable

Corma doesn't:

- Autoload or lazy load relationships by default
- Do migrations or code generation

Works in MySql and PostgreSQL.

Install via Composer
--------------------

[](#install-via-composer)

Via the command line:

```
composer.phar require thewunder/corma ^5.0

```

Or add the following to the require section your composer.json:

```
"thewunder/corma": "^5.0"

```

For PHP versions &lt; 8.1 use Corma version ~3.0

Basic Usage
-----------

[](#basic-usage)

Create a DataObject

```
namespace YourNamespace\Dataobjects;

use Corma\Relationship\ManyToMany;
use Corma\Relationship\OneToMany;
use Corma\Relationship\OneToOne;

class YourDataObject {
    protected $id;

    //If the property name == column name on the table your_data_objects it will be saved
    protected $myColumn;

    protected ?int $otherObjectId = null;

    #[OneToOne]
    protected ?OtherObject $otherObject = null;

    #[OneToMany(AnotherObject::class)]
    protected ?array $anotherObjects = null;

    #[ManyToMany(DifferentObject::class, 'your_data_object_different_link_table')]
    protected ?array $differentObjects = null;
    //Getters and setters..
}
```

And a Repository (optional)

```
namespace YourNamespace\Dataobjects\Repository;

class YourDataObjectRepository extends ObjectRepository {
    //Override default behavior and add custom methods...
}
```

Create the orm and use it

```
$db = DriverManager::getConnection(...); //see Doctrine DBAL docs
$orm = ObjectMapper::withDefaults($db, $container); //uses any PSR-11 compatible DI container

$object = $orm->create(YourDataObject::class);
//Call setters...
$orm->save($object);
//Call more setters...
$orm->save($object);

//Call more setters on $object...
$objects = [$object];
$newObject = $orm->create(YourDataObject::class);
//call setters on $newObject...
$objects[] = $newObject;

$orm->saveAll($objects);

//find existing object by id
$existingObject = $orm->find(YourDataObject::class, 5);

//find existing objects with myColumn >= 42 AND otherColumn = 1
$existingObjects = $orm->findBy(YourDataObject::class, ['myColumn >='=>42, 'otherColumn'=>1], ['sortColumn'=>'ASC']);

//load relationships
$orm->load($existingObjects, 'otherObject');
$orm->load($existingObjects, 'anotherObjects');
$orm->load($existingObjects, 'differentObjects');

//delete those
$orm->deleteAll($existingObjects);
```

Documentation
-------------

[](#documentation)

See [the wiki](https://github.com/thewunder/corma/wiki) for full documentation.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance66

Regular maintenance activity

Popularity38

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 98.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~92 days

Total

88

Last Release

241d ago

Major Versions

1.0.6 → 2.0-beta12016-04-29

1.0.7 → 2.02016-05-03

2.x-dev → 3.0-beta12017-05-04

3.6.5 → 4.02022-05-24

4.x-dev → 5.x-dev2024-09-16

PHP version history (6 changes)0.1PHP &gt;=5.4

0.2.0PHP &gt;=5.5

3.0-beta1PHP &gt;=7.1

3.4.0PHP &gt;=7.2

4.0PHP &gt;=8.0

4.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf016ae612f01684bc359174b8bb8db688a3de817457829ea83da6690df975f0?d=identicon)[thewunder](/maintainers/thewunder)

---

Top Contributors

[![thewunder](https://avatars.githubusercontent.com/u/1265740?v=4)](https://github.com/thewunder "thewunder (225 commits)")[![jobrie12](https://avatars.githubusercontent.com/u/4553375?v=4)](https://github.com/jobrie12 "jobrie12 (2 commits)")[![jblotus](https://avatars.githubusercontent.com/u/382230?v=4)](https://github.com/jblotus "jblotus (1 commits)")

---

Tags

databaseormphpdata mapperObject relational mapper

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/thewunder-corma/health.svg)

```
[![Health](https://phpackages.com/badges/thewunder-corma/health.svg)](https://phpackages.com/packages/thewunder-corma)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[patchlevel/event-sourcing

A lightweight but also all-inclusive event sourcing library with a focus on developer experience

198283.8k7](/packages/patchlevel-event-sourcing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
