xm/doctrine-entity-repository

A different method of creating entity repositories for use with Doctrine.

1.0.0 2017-08-17 05:11 UTC

This package is auto-updated.

Last update: 2024-11-15 14:49:30 UTC


README

A different way of creating Doctrine Repositories based on this article by Magnus Nordlander. The main difference (as opposed to "normal" Doctrine Repositories) is that these can be autowired by Symfony. We've also found them easier to test.

Repositories extending this class should not be referenced by the repositoryClass entity mapping. But the repository can be used in the same way as "normal" Doctrine Entity Repositories.

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

composer require xm/doctrine-entity-repository

This command requires Composer.

Usage

<?php

namespace AppBundle\Repository;

use AppBundle\Entity\User;
use XM\EntityRepository;

class UserRepository extends EntityRepository
{
    /**
     * The entity class name that the repository is for.
     * Required. 
     */
    protected $class = User::class;
    
    // ... custom methods
}