Download the PHP package matthiasnoback/talis-orm without Composer
On this page you can find all versions of the php package matthiasnoback/talis-orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package talis-orm
About TalisORM
A good design starts with some limitations. You can start simple and keep building until you have a large ORM like Doctrine. Or you can choose not to support a mapping configuration, table inheritance, combined write/read models, navigable object graphs, lazy-loading, etc. That's what I'm looking for with TalisOrm. The rules are:
- You model a persistable domain object as an Aggregate: one (root) Entity, and optionally some Child entities.
- The child entities themselves have no children.
- You use the ORM for your write model only. That is, you don't need to fetch hundreds of these aggregates to show them to the user.
- Your aggregate internally records domain events, which will automatically be released and dispatched after saving changes to the aggregate.
Furthermore:
- You're going to write your own mapping code, which converts your values or Value objects to and from column values.
I explain more about the motivation for doing this in "ORMless; a Memento-like pattern for object persistence".
You can find some examples of how to use this library in test/TalisOrm/AggregateRepositoryTest/.
Recording and dispatching domain events
A domain event is a simple object indicating that something has happened inside an aggregate (usually this just means that something has changed). You can use the EventRecordingCapabilities
trait to save yourself from rewriting a couple of simple lines over and over again.
Immediately after saving an aggregate, the EventDispatcher
. As a user of this library you have to provide your own implementation of this interface, which is very simple. Maybe you just want to forward the call to your favorite event dispatcher, or the one that ships with your framework.
Managing the database schema
Aggregates can implement SpecifiesSchema
and, yes, specify their own schema. This can be useful if you want to use a tool to synchronize your current database schema with the schema that your aggregates expect, e.g. the Doctrine DBAL's own SingleDatabaseSynchronizer
:
You could also use Doctrine Migrations to automatically generate migrations based on schema changes. It may need a bit of setup, but once you have it working, you'll notice that this tool needs a SchemaProviderInterface
instance (note: this interface is only available in recent versions of doctrine/migrations
, which requires PHP 7). You can easily set up an adapter for AggregateSchemaProvider
. For example:
Protecting against concurrent updates
Traditionally, we PHP developers aren't used to protect our aggregates against concurrent updates. Concurrent updates after all are a matter of chance. Maybe there aren't that many users who are working on the same aggregate in your project. But if you're worried that it might happen, there's an easy solution built-in to TalisORM: optimistic concurrency locking.
You need to take the following steps to make it work:
Make sure the table definition for your aggregate has an Aggregate::VERSION_COLUMN
column, and that your fromState()
and state()
methods are aware of it. For example:
The above setup will protect your aggregate against concurrent updates between retrieving the aggregate from the database and saving it again. However, you may want to warn a user who's working with the aggregate's data in the user interface that once they store the object, someone else has modified it. To do this, you need to remember the version of the aggregate the user is looking at in the user's session. An outline of this solution:
All versions of talis-orm with dependencies
doctrine/dbal Version ^2.5
webmozart/assert Version ^1.4
ext-pdo Version *
composer/package-versions-deprecated Version 1.11.99.1