PHPackages                             gridonic/repository-service-provider - 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. gridonic/repository-service-provider

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

gridonic/repository-service-provider
====================================

Doctrine repository service provider for Silex

1.0.1(11y ago)0141MITPHPPHP &gt;=5.3.2

Since Oct 21Pushed 11y ago8 watchersCompare

[ Source](https://github.com/gridonic/RepositoryServiceProvider)[ Packagist](https://packagist.org/packages/gridonic/repository-service-provider)[ Docs](http://gridonic.ch)[ RSS](/packages/gridonic-repository-service-provider/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Doctrine repository service provider for Silex
==============================================

[](#doctrine-repository-service-provider-for-silex)

This service provider exposes an easy way to have Repositories for your silex database.

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

[](#requirements)

This service provider has ben built to work with the `DoctrineServiceProvider` silex extension. See [Silex' DoctrineServiceProvider documentation](http://silex.sensiolabs.org/doc/providers/doctrine.html) for instruction on how to use it.

Configuration
-------------

[](#configuration)

Add the the repository to your dependencies, then register the autoload:

```
$app['autoloader']->registerNamespaces(array(
    /** Your other namespaces **/
    'Knp' => __DIR__.'/../vendor/KnpSilexExtensions/'
));

```

Register the service provider:

```
$app->register(
    new Knp\Provider\RepositoryServiceProvider(), array(
        'repository.repositories' => array(
            'projects' => 'MyProject\Repository\Project',
        )
    )
);

```

The service provider expects parameter `repository.repositories` to be set and to be an associative array with service names as keys and repository classes as values.

In the example above, the `projects` service will be exposed by Pimple (ie, you can access it through `$app['projects']`) using the `MyProject\Repository\Project` class.

Usage
-----

[](#usage)

As you might have guessed by now, you need to implement a concrete class for every repository that you want to use. That repository must extend `Knp\Repository` and implement the `getTableName` method, that should return the database's table name bound to that repository.

In the example above, given your projects are stored in the `project` table, the `MyProject\Repository\Project` class would look like that:

```
