PHPackages                             bullet/doctrine-utils - 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. bullet/doctrine-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bullet/doctrine-utils
=====================

This is my package doctrine-utils

v1.0.1(1y ago)0514[1 PRs](https://github.com/BulletDigitalSolutions/doctrine-utils/pulls)MITPHPPHP ^8.1|^8.2

Since Jul 24Pushed 1y ago2 watchersCompare

[ Source](https://github.com/BulletDigitalSolutions/doctrine-utils)[ Packagist](https://packagist.org/packages/bullet/doctrine-utils)[ Docs](https://github.com/BulletDigitalSolutions/doctrine-utils)[ GitHub Sponsors](https://github.com/Bullet)[ RSS](/packages/bullet-doctrine-utils/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (8)Versions (5)Used By (0)

Doctrine Utils
==============

[](#doctrine-utils)

Doctrine Utils is a package designed to enhance the functionality of Laravel applications by integrating advanced features for better route model bindings using Doctrine ORM.

Features
--------

[](#features)

### Route Model Bindings

[](#route-model-bindings)

This feature allows you to replace Laravel's default model binding with Doctrine's powerful ORM capabilities. By using Doctrine for model binding, you can take full advantage of Doctrine's features for retrieving entities.

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

[](#installation)

To install the Route Model Bindings feature, follow these steps:

1. **Replace Laravel Middleware:**Replace the default Laravel "substitute bindings" middleware with the middleware provided by Doctrine Utils. Update your `Kernel.php` middleware configuration to use the following middleware:

    ```
    // In app/Http/Kernel.php
    protected $middlewareGroups = [
        'web' => [
            \Bullet\DoctrineUtils\Http\Middleware\SubstituteBindings::class,
            'domain.redirect',
        ],
    ];
    ```
2. **Implement UrlRoutable Interface:**Add the `UrlRoutable` interface to your base entity and implement the required methods. This interface is necessary for the middleware to resolve route bindings using Doctrine's entity repository. Here is an example of how to implement it:

    ```
    namespace App\Entities;

    use Bullet\DoctrineUtils\Interfaces\UrlRoutable;

    class BaseEntity implements UrlRoutable
    {
        // Implement the required methods

        /**
         * Resolve the route binding.
         *
         * @param mixed $value
         * @param string|null $field
         * @return mixed
         */
        public static function resolveRouteBinding($value, $field = null)
        {
            $field = $field ?? self::getRouteKeyName();
            return self::repository()->findOneBy([$field => $value]);
        }

        /**
         * Get the route key name.
         *
         * @return string
         */
        public static function getRouteKeyName(): string
        {
            return 'id';
        }

        /**
         * Get the repository for the entity.
         *
         * @return \Doctrine\ORM\EntityRepository
         */
        public static function repository()
        {
            return app('em')->getRepository(get_called_class());
        }
    }
    ```

Usage
-----

[](#usage)

Once installed, the Doctrine Utils package will automatically handle route model bindings using Doctrine's entity repository. This allows you to define routes and controllers in Laravel as usual, while benefiting from the enhanced ORM capabilities provided by Doctrine.

### Example

[](#example)

Here is an example of how it works:

1. **Define Routes:**

    ```
    use Illuminate\Support\Facades\Route;

    Route::get('{plant}', [PlantController::class, 'show']);
    Route::get('{plant:slug}', [PlantController::class, 'showBySlug']);
    ```
2. **Controller Methods:**

    ```
    namespace App\Http\Controllers;

    use App\Entities\Plant;
    use Illuminate\Http\Request;
    use Symfony\Component\HttpFoundation\Response;

    class PlantController extends Controller
    {
        /**
         * Show the plant details.
         *
         * @param Plant $plant
         * @param Request $request
         * @return Response
         */
        public function show(Plant $plant, Request $request): Response
        {
            // Handle the request with the injected Plant entity
        }

        /**
         * Show the plant details by slug.
         *
         * @param Plant $plant
         * @param Request $request
         * @return Response
         */
        public function showBySlug(Plant $plant, Request $request): Response
        {
            // Handle the request with the injected Plant entity
        }
    }
    ```

Requirements
------------

[](#requirements)

- Laravel 8.x or higher
- Doctrine ORM

License
-------

[](#license)

Doctrine Utils is open-source software licensed under the MIT license. Feel free to contribute or modify the package to suit your needs.

Contributing
------------

[](#contributing)

If you would like to contribute to Doctrine Utils, please fork the reposit

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Total

3

Last Release

627d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0976cfdfec8c8b08fbc1f61db9d2e5189f8b3bff096149cb7b70c54cf988a709?d=identicon)[bullet](/maintainers/bullet)

---

Top Contributors

[![andy3471](https://avatars.githubusercontent.com/u/7016492?v=4)](https://github.com/andy3471 "andy3471 (14 commits)")

---

Tags

laravelbulletdoctrine-utils

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/bullet-doctrine-utils/health.svg)

```
[![Health](https://phpackages.com/badges/bullet-doctrine-utils/health.svg)](https://phpackages.com/packages/bullet-doctrine-utils)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20619.4k](/packages/stephenjude-filament-blog)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11273.0k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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