PHPackages                             somnambulist/entity-behaviours - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. somnambulist/entity-behaviours

Abandoned → [somnambulist/domain](/?search=somnambulist%2Fdomain)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

somnambulist/entity-behaviours
==============================

A set of behaviours and interfaces for use with entities

1.2.1(8y ago)03.5k1MITPHPPHP &gt;=7

Since Jul 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/dave-redfern/somnambulist-entity-behaviours)[ Packagist](https://packagist.org/packages/somnambulist/entity-behaviours)[ RSS](/packages/somnambulist-entity-behaviours/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (6)Used By (1)

Moved to
==============================================================

[](#moved-to-httpsgithubcomdave-redfernsomnambulist-domain)

This repository has been archived. Please update to the combined package.s

Entity Behaviours
-----------------

[](#entity-behaviours)

Provides some useful interfaces and traits that can be used with entities. The traits implement on basic methods, and still require e.g. publish/unpublish to be implemented.

### Requirements

[](#requirements)

- PHP 7+

### Installation

[](#installation)

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

- composer require somnambulist/entity-behaviours

### Behaviours

[](#behaviours)

Unlike the somnambulist/laravel-doctrine-behaviours package, these behaviours are intended to be used in a much more controlled and DDD based system. As such they do not implement setters and in some cases even the methods defined in the interfaces as these are core domain methods that should raise events within your system.

1. Activatable

    Adds `activate()`/`deactivate()` methods to an entity controlling if it is active or not. The entity should implement activate/deactivate methods so that Events can be raised.
2. GloballyTrackable

    A collection of other interfaces: Identifiable, Nameable, Timestampable, UniversallyIdentifiable.
3. Identifiable

    Adds an `id()` method that returns the primary identifier (int, string, object)
4. IdentifiableWithTimestamps

    A combination of Identifiable and Timestampable
5. Nameable

    Adds a `name()` method that returns the entity name component.
6. NumericallySortable

    Adds an `ordinal()` and update method for adding a numerical sorting index to an entity.
7. Publishable

    Adds `publish()`/`unpublish()` for controlling if an Entity is "published". Uses the DateTime value object. publish/unpublish are not implemented as they should raise events when used.
8. Stringable

    Adds `__toString()` and a `toString()` method that will use try the following methods:

    - `displayAs()`
    - `title()`
    - `name()`

    If none are present an empty string is returned.
9. Timestampable

    Adds `createdAt()`/`updatedAt()` methods. Not setters are not defined as the entity should update the updatedAt when it is changed through update calls and not rely on database behaviour.
10. Trackable

    A collection of other interfaces: Identifiable, Nameable, Timestampable
11. UniversallyIdentifiable

    Adds a `uuid()` method that returns a Uuid value object.
12. Versionable

    Adds a `version()` and `incrementVersion()` methods for defining the current entity version. incrementVersion should be hooked in appropriate update methods when the entity is modified.

### Utilities

[](#utilities)

- EntityAccessor

    Helper class for accessing property methods/properties. Intended to be used in unit tests only.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

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 ~24 days

Total

5

Last Release

3177d ago

### 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 (2 commits)")

---

Tags

dddentitiesbehaviours

### Embed Badge

![Health badge](/badges/somnambulist-entity-behaviours/health.svg)

```
[![Health](https://phpackages.com/badges/somnambulist-entity-behaviours/health.svg)](https://phpackages.com/packages/somnambulist-entity-behaviours)
```

###  Alternatives

[prooph/service-bus

PHP Enterprise Service Bus Implementation supporting CQRS and DDD

4421.4M32](/packages/prooph-service-bus)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[prooph/event-sourcing

PHP EventSourcing library

265818.8k18](/packages/prooph-event-sourcing)[phpmentors/domain-kata

Kata for domain models

73441.4k9](/packages/phpmentors-domain-kata)[aura/payload

A Domain Payload implementation.

55377.9k9](/packages/aura-payload)[bruli/php-value-objects

PHP Value objects to use for DDD domains.

43321.3k8](/packages/bruli-php-value-objects)

PHPackages © 2026

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