PHPackages                             somnambulist/laravel-doctrine-entity-validation - 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. somnambulist/laravel-doctrine-entity-validation

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

somnambulist/laravel-doctrine-entity-validation
===============================================

Provides integration between Doctrine entities and Laravel Validator.

0.1.2(9y ago)05852MITPHPPHP &gt;=7.0

Since Aug 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/dave-redfern/laravel-doctrine-entity-validation)[ Packagist](https://packagist.org/packages/somnambulist/laravel-doctrine-entity-validation)[ RSS](/packages/somnambulist-laravel-doctrine-entity-validation/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (5)Versions (4)Used By (2)

This project is no longer being maintained.

Entity Validation for Laravel-Doctrine ORM
------------------------------------------

[](#entity-validation-for-laravel-doctrine-orm)

Provides integration between standard Doctrine entities and the Laravel Validator by using Hydrators.

### Requirements

[](#requirements)

- PHP 7+
- Laravel 5.2+
- laravel-doctrine/orm

### Installation

[](#installation)

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

- composer install somnambulist/laravel-doctrine-entity-validation
- add the service provider to your config/app.php file
- php artisan vendor:publish

Two new config files will added:

- doctrine\_hydrators.php
- doctrine\_validation.php

Add the entity class names to the hydrators config file to have hydrators made. Add a mapping between the entity and a rules class in validation to allow the factory class to create Validator instances.

The validation rules should implement the EntityRules contract or extend: `Somnambulist\EntityValidation\AbstractEntityRules` class. The rules class should contain the basic rules needed to validate the entity. This is **NOT** form validation! These rules are the basic requirements for your domain entities to be valid.

The validation rules can then be added to your form requests or validation rules. E.g.: a User entity may have EntityRules requiring a name, email and username but in the AddUserFormRequest, Roles and Permissions may be additionally required. The entity rules would look something like:

```
class UserEntityRules extends AbstractRules
{
    public function supports($entity)
    {
        return $entity instanceof User;
    }

    protected function buildRules($entity)
    {
        return [
            'name' => 'required|min:1',
            'email' => 'required|email|unique:User,email,' . ($entity->getId() ?: 'null'),
            'username' => 'required|alphanum|unique:User,username,' . ($entity->getId() ?: 'null'),
        ];
    }
}

```

As the entity is passed in, you can access any method and create complex rules.

The entity validation factory can then be type-hinted or fetched from the container:

```
class SomeClass ...
{
    public function __construct(EntityValidationFactory $validationFactory)
    {
        $this->factory = $validationFactory;
    }
    public function someMethod()
    {
        if ($this->factory->validate($user)) {

        }
    }
}

```

### Generating Hydrators

[](#generating-hydrators)

An extra command is provided to make generating the hydrators easier:

```
php artisan doctrine:generate:hydrators

```

These will be cached to the file system in the storage/cache/hydrators folder by default. Configure the storage folder in the hydrators config file.

This command can be added to `composer install|update` so that the hydrators are created automatically as changes are made or code deployed.

- *Note*: it is not a requirement to cache the hydrators, however it offers much better performance in production.
- *Note*: it is good to add doctrine:generate:proxies before the hydrators.

Links
-----

[](#links)

- [Entity Auditing (port of SimpleThings: EntityAudit)](https://github.com/dave-redfern/laravel-doctrine-entity-audit)
- [Domain Events for Laravel with Doctrine](https://github.com/dave-redfern/laravel-doctrine-domain-events)
- [Multi-Tenancy for Laravel with Doctrine](https://github.com/dave-redfern/laravel-doctrine-tenancy)
- [Laravel Doctrine](http://laraveldoctrine.org)
- [Laravel](http://laravel.com)
- [Doctrine](http://doctrine-project.org)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

3

Last Release

3431d 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 (1 commits)")

---

Tags

entityentity-validationhydratorlaravellaravel-doctrinelaravel-validationlaravelvalidationdoctrinelaravel-doctrine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/somnambulist-laravel-doctrine-entity-validation/health.svg)

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

###  Alternatives

[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8385.5M96](/packages/laravel-doctrine-orm)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[laravel-doctrine/migrations

Doctrine Migrations for Laravel

782.8M17](/packages/laravel-doctrine-migrations)[laravel-doctrine/extensions

Doctrine extensions for Laravel

493.6M19](/packages/laravel-doctrine-extensions)[esensi/model

The base model traits of Esensi

20067.0k1](/packages/esensi-model)

PHPackages © 2026

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