PHPackages                             somnambulist/read-models-bundle - 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. somnambulist/read-models-bundle

ActiveSymfony-bundle

somnambulist/read-models-bundle
===============================

Symfony integration for somnambulist/read-models

3.1.0(2y ago)12.0k1MITPHPPHP &gt;=8.1

Since Sep 8Pushed 1y ago3 watchersCompare

[ Source](https://github.com/somnambulist-tech/read-models-bundle)[ Packagist](https://packagist.org/packages/somnambulist/read-models-bundle)[ RSS](/packages/somnambulist-read-models-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (7)Used By (1)

Read-Models Bundle for Symfony
==============================

[](#read-models-bundle-for-symfony)

[![GitHub Actions Build Status](https://camo.githubusercontent.com/43359bbfbe2ac68d39d389d87381f7af03640bcd2da004c1d0c4d38e2d15a203/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f6d6e616d62756c6973742d746563682f726561642d6d6f64656c732d62756e646c652f74657374732e796d6c3f6c6f676f3d676974687562266272616e63683d6d61696e)](https://github.com/somnambulist-tech/read-models-bundle/actions?query=workflow%3Atests)[![Issues](https://camo.githubusercontent.com/2d6e435c54388e0cd17a3468b35aa46a9266b8009e5193ea77a9fa9e31796b2a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736f6d6e616d62756c6973742d746563682f726561642d6d6f64656c732d62756e646c653f6c6f676f3d676974687562)](https://github.com/somnambulist-tech/read-models-bundle/issues)[![License](https://camo.githubusercontent.com/601200e15fbc74f71520445ea525d60047fb99c4bfbb892c19d00fa3de1eb91e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736f6d6e616d62756c6973742d746563682f726561642d6d6f64656c732d62756e646c653f6c6f676f3d676974687562)](https://github.com/somnambulist-tech/read-models-bundle/blob/master/LICENSE)[![PHP Version](https://camo.githubusercontent.com/f27e4ab81ecc571d0ef0d473949e6be2174e1fbb3446d765f9da9667b39cd9f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6d6e616d62756c6973742f726561642d6d6f64656c732d62756e646c653f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/somnambulist/read-models-bundle)[![Current Version](https://camo.githubusercontent.com/b6b2ea8c985e01d3754b6d6a6786e1323c5e9e987c467af93ea96867f88330c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6d6e616d62756c6973742f726561642d6d6f64656c732d62756e646c653f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/somnambulist/read-models-bundle)

Integrates [read-models](https://github.com/somnambulist-tech/read-models) into Symfony via a bundle.

Installation
------------

[](#installation)

Install using composer, or checkout / pull the files from github.com.

- composer require somnambulist/read-models-bundle
- add the bundle class to `config/bundles.php` as the last bundle
    - **Note:** if not configured last, then any custom doctrine types may not be assigned to the type caster as the Manager will boot too soon.
- add a config file (`config/packages/somnambulist.yaml`) with the configuration
- map any custom casters via the `services.yaml` and tags
- make some models
- load some data: `::find()`

An example config in `config/packages/somnambulist.yaml` could be:

```
somnambulist_read_models:
    connections:
        'default': 'doctrine.dbal.default_connection'
        'App\Models\User': 'doctrine.dbal.user_connection'
    subscribers:
        request_manager_clearer: true
        messenger_manager_clearer: true
```

There are 2 event subscribers that are auto-registered:

- identity map clear on kernel request, terminate
- messenger clear on message handled / failed

If messenger is not installed, the listener will be disabled automatically.

### Connections

[](#connections)

Each model type can have a custom connection by using the fully qualified class name as the key. When referencing the Doctrine connections, be sure to leave off the `@` prefix if copying from elsewhere.

Note that if the default is not specified, then the currently configured Doctrine default will be auto-registered.

### Adding Attribute Casters

[](#adding-attribute-casters)

Add attribute casters as services and tag them with: `somnambulist.read_models.type_caster` to have them automatically registered with the `Manager`s attribute caster instance.

To use the `attribute-model` generic type casters, and them as services and configure as needed:

```
services:
    app.type_casters.some_service_identity:
        class: Somnambulist\Components\AttributeModel\TypeCasters\ExternalIdentityCaster
        arguments:
            $providerAttribute: 'some_service_name'
            $identityAttribute: 'some_service_id'
            $remove: true
            $types:
                -
                    some_service_id
        tags: ['somnambulist.read_models.type_caster']

    app.type_casters.my_value_object:
        class: Somnambulist\Components\AttributeModel\TypeCasters\SimpleValueObjectCaster
        arguments:
            $class: 'App\\Entities\\SomeEntityValueObject'
            $types:
                -
                    short_name
        tags: ['somnambulist.read_models.type_caster']
```

Or if you don't need configuration, or have your own; use a resource:

```
services:
    App\TypeCasters\:
        resource: '../../src/TypeCasters/'
        tags: ['somnambulist.read_models.type_caster']
```

The attribute names should be the array key names that the values are expected to appear in from the data source. For example: if a `Product` model accesses a `products` table that has `unit_value`and `unit_cur` fields, this could be converted to a `Money` object by using the `MoneyCaster`:

```
services:
    app.type_casters.product_money_caster:
        class: Somnambulist\Components\AttributeModel\TypeCasters\MoneyCaster
        arguments:
            $amtAttribute: 'unit_value'
            $curAttribute: 'unit_cur'
            $remove: true
            $types:
                -
                    product_price
        tags: ['somnambulist.read_models.type_caster']
```

Then the caster can be referenced in the casts as: `'price' => 'product_price'` and the unit\_value and unit\_cur attributes will be removed in favour of the single "price" attribute that will be a Money value object. If the originals should be left in place, set `$remove` to `false`.

Additional casters can be added at any time; and existing casters may be overridden by re-using an existing type name however this is discouraged. Note that once a type is registered it cannot be removed.

Usage
-----

[](#usage)

See [read-models](https://github.com/somnambulist-tech/read-models) for detailed docs on usage and [attribute-models](https://github.com/somnambulist-tech/attribute-model) for more on the attribute caster.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~254 days

Recently: every ~316 days

Total

6

Last Release

797d ago

Major Versions

1.1.0 → 2.0.02021-01-21

2.1.0 → 3.0.02023-01-19

PHP version history (3 changes)1.0.0PHP &gt;=7.4

2.0.0PHP &gt;=8.0

3.0.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![dave-redfern](https://avatars.githubusercontent.com/u/1477147?v=4)](https://github.com/dave-redfern "dave-redfern (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/somnambulist-read-models-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/somnambulist-read-models-bundle/health.svg)](https://phpackages.com/packages/somnambulist-read-models-bundle)
```

###  Alternatives

[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[rikudou/psr6-dynamo-db-bundle

PSR-6 and PSR-16 cache implementation using AWS DynamoDB for Symfony

2077.8k](/packages/rikudou-psr6-dynamo-db-bundle)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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