Skip to content

Latest commit

 

History

History
76 lines (59 loc) · 2.23 KB

README.md

File metadata and controls

76 lines (59 loc) · 2.23 KB

Symfony - Repository as a Service (RaaS)

SensioLabsInsight Dependency Status Latest Stable Version Total Downloads License

This bundle allows to register repositories as a service.

Install instructions

Installing this bundle can be done through these simple steps:

Add the bundle to your project as a composer dependency:

// composer.json
{
    // ...
    require: {
        // ...
        "shapecode/repository-as-a-service": "~1.2"
    }
}

Update your composer installation:

$ composer update

Add the bundle to your application kernel:

<?php

// application/ApplicationKernel.php
public function registerBundles()
{
	// ...
	$bundle = array(
		// ...
        new Shapecode\Bundle\RasSBundle\ShapecodeRasSBundle(),
	);
    // ...

    return $bundles;
}

Start using the bundle and set repositories as services:

app.repository.example:
    class: %app.repository.example.class%
    tags:
        -  { name: doctrine.repository, class: %app.entity.example.class%, alias: example_repository }

or let the bundle do the job for you. It creates automatically services for you. Just access it with "lowercaseentitnyname_repository".

<?php

$this->getContainer()->get('lowercaseentitnyname_repository');

The old way to get repository is also supported. If you get them like this ...

<?php

$this->getRepository('ShapecodeRasSBundle:TestEntity');

... you get the service off the repository instead.