PHPackages                             knplabs/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. [Framework](/categories/framework)
4. /
5. knplabs/repository-service-provider

AbandonedArchivedLibrary[Framework](/categories/framework)

knplabs/repository-service-provider
===================================

Doctrine repository service provider for Silex

1913.3k↓50%15[1 PRs](https://github.com/KnpLabs/RepositoryServiceProvider/pulls)PHP

Since Sep 23Pushed 3y ago29 watchersCompare

[ Source](https://github.com/KnpLabs/RepositoryServiceProvider)[ Packagist](https://packagist.org/packages/knplabs/repository-service-provider)[ RSS](/packages/knplabs-repository-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

DEPRECATED
==========

[](#deprecated)

Unfortunately we decided to not maintain this project anymore ([see why](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance)). If you want to mark another package as a replacement for this one please send an email to .

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 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:

```
