PHPackages                             atlas/transit - 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. atlas/transit

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

atlas/transit
=============

A datasource-domain mapping system.

0.x-dev(7y ago)7833[4 issues](https://github.com/atlasphp/Atlas.Transit/issues)[3 PRs](https://github.com/atlasphp/Atlas.Transit/pulls)1MITPHPPHP &gt;=7.1.0

Since Dec 22Pushed 3y ago4 watchersCompare

[ Source](https://github.com/atlasphp/Atlas.Transit)[ Packagist](https://packagist.org/packages/atlas/transit)[ Docs](http://github.com/atlasphp/Atlas.Transit)[ RSS](/packages/atlas-transit/feed)WikiDiscussions 0.x Synced yesterday

READMEChangelog (2)Dependencies (4)Versions (10)Used By (1)

Atlas.Transit
=============

[](#atlastransit)

Moves data from Atlas persistence Records and RecordSets; to domain Entities, Aggregates, and collections; and back again.

- Creates domain Entities and Aggregates with constructor parameter values taken from fields in a source Record; updates the source Record fields from the domain Entity and Aggregate properties; refreshes Entities with autoincrement values after source inserts.
- Creates domain collection members from Records in a RecordSet; updates Records in the RecordSet from the domain collection members.
- Allows for common case conversion between Records and domain objects (`snake_case`, `camelCase`, `PascalCase`); defaults to `snake_case` on the Record side and `camelCase` on the domain side.
- Allows for custom conversion of values between source Records and domain objects.
- Provides `select($domainClass) ... ->fetchDomain()` functionality for creating domain objects fluently from Atlas.Orm queries.

Atlas.Transit depends on a number of conventions in the Domain implementation:

- That you can build an entire Entity or Aggregate from the values in a single Record (i.e., both the Row and the Related for the Record).
- That domain Entities and Aggregates take constructor parameters for their creation, and that the constructor parameter names are identical to their internal property names.
- That Aggregates have their Aggregate Root (i.e., their root Entity) as their first constructor parameter.
- That Collections use the member class name suffixed with 'Collection'. (NOTE: This is only so that Transit can find the mapper; if you want, you can specify the mapper with the `@Atlas\Transit\Source\Mapper` annotation.)
- That Collections take a single constructor parameter: an array of the member objects in the collection.
- That Collections are traversable/interable, and return the member objects when doing so.

Finally, unlike Atlas.Orm and its supporting packages, Atlas.Transit makes some light use of annotations; this is to help keep the Domain layer as free from the persistence layer as possible. Annotate your domain classes as follows to help Transit identify their purpose in the domain:

- Entities are annotated with `@Atlas\Transit\Entity`
- Collections are annotated with `@Atlas\Transit\Collection`
- Aggregates are annotated with `@Atlas\Transit\Aggregate`
- Value Objects are annotated with `@Atlas\Transit\ValueObject`

Your entity classes are presumed by default to have the same names as your persisence mapper classes. For example, a domain class named `Thread`automatically uses a source mapper class named `Thread`. If your entity class uses a different source mapper, add the fully-qualified mapper class name:

```
/**
 * @Atlas\Transit\Entity App\DataSource\Other\Other
 */
```

Example
-------

[](#example)

```
$transit = Transit::new(
    Atlas::new('sqlite::memory:'),
    'App\\DataSource\\', // data source namespace
);

// select records from the mappers to create entities and collections
$thread = $transit
    ->select(Thread::CLASS) // the domain class
    ->where('id = ', 1)
    ->fetchDomain();

$responses = $transit
    ->select(Responses::CLASS) // the domain class
    ->where('thread_id IN ', [2, 3, 4])
    ->fetchDomain();

// do stuff to $thread and $responses

// then plan to save/update all of $responses ...
$transit->store($responses);

// ... and plan to delete $thread
$transit->discard($thread);

// finally, persist all the domain changes in Transit
$success = $transit->persist();
```

Value Objects
-------------

[](#value-objects)

For embedded Value Objects, you need to implement the following methods in each Value Object class to move data from and back into the source Record objects. The example code is the minimum for a naive transit back-and-forth:

```
/**
 * @Atlas\Transit\ValueObject
 * @Atlas\Transit\Factory self::transitFactory()
 * @Atlas\Transit\Updater self::transitUpdater()
 */
class ...
{
    private static function transitFactory(object $record, string $field) : self
    {
        return new self($record->$field);
    }

    private static function transitUpdater(self $domain, object $record, string $field) : void
    {
        $record->$field = $domain->$field;
    }
}
```

Note that Record-backed Value Objects are going to be very tricky.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance9

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~81 days

Total

3

Last Release

2700d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25754?v=4)[Paul M. Jones](/maintainers/pmjones)[@pmjones](https://github.com/pmjones)

---

Top Contributors

[![pmjones](https://avatars.githubusercontent.com/u/25754?v=4)](https://github.com/pmjones "pmjones (7 commits)")[![adamdyson](https://avatars.githubusercontent.com/u/609950?v=4)](https://github.com/adamdyson "adamdyson (1 commits)")[![ElGigi](https://avatars.githubusercontent.com/u/18268216?v=4)](https://github.com/ElGigi "ElGigi (1 commits)")

---

Tags

ormmappingmapperdomain

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/atlas-transit/health.svg)

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

###  Alternatives

[doctrine/persistence

The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

4.0k298.2M966](/packages/doctrine-persistence)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k24.1M346](/packages/doctrine-mongodb-odm)[atlas/orm

An ORM for your persistence model (not your domain model).

429142.5k12](/packages/atlas-orm)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[vlucas/spot2

Simple DataMapper built on top of Doctrine DBAL

597395.2k7](/packages/vlucas-spot2)[doctrine/phpcr-odm

PHP Doctrine Content Repository Object Document Mapper (ODM) provides transparent persistence for PHP objects.

1811.5M102](/packages/doctrine-phpcr-odm)

PHPackages © 2026

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