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

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

insolis/repository-service-provider
===================================

Doctrine repository service provider for Silex

v2.0(9y ago)0201MITPHPPHP &gt;=5.5.9

Since Jul 19Pushed 9y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (5)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.

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

[](#installation)

Add `insolis/repository-service-provider` to your `composer.json` file.

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

[](#configuration)

Register the service provider:

```
$app->register(
    new Insolis\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 `Insolis\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:

```
namespace MyProject\Repository;

use Insolis\Repository;

class Project extends Repository;
{
    public function getTableName()
    {
        return 'project';
    }
}
```

The default repository implementation exposes a number of methods to manipulate your database that are basically proxies to methods from `Doctrine\DBAL\Connection`:

### `insert(array $data)`

[](#insertarray-data)

```
$app['projects']->insert(array(
    'title'       => 'foo',
    'description' => 'A project'
));
```

Will insert a project in the table with `title` "foo" and `description` "A project".

### `update(array $data, array $identifier)`

[](#updatearray-data-array-identifier)

```
$app['projects']->update(array('title' => 'bar'), array('title' => 'foo'));
```

Will update all projects' `title` from "foo" to "bar".

### `delete(array $identifier)`

[](#deletearray-identifier)

```
$app['projects']->delete(array('title' => 'bar'));
```

Will delete all projects which title is "bar".

### `find($id)`

[](#findid)

```
$app['projects']->find(42);
```

Returns the project which id field is 42.

### `findAll()`

[](#findall)

```
$app['projects']->findAll();
```

Returns the entire table content.

### `count()`

[](#count)

```
$app["projects"]->count();
```

Returns the count of all records in the table.

### Extending a repository

[](#extending-a-repository)

Extending a repository is as easy as adding methods to it. For example, you could add a `findByTitle($title)` method to return all projects based on their title:

```
public function findByTitle($title)
{
    return $this->db->fetchAll(sprintf("SELECT * FROM %s WHERE title = ?;",
        $this->getTableName()), array($title));
}
```

Credits
-------

[](#credits)

- [KnpLabs](http://knplabs.com/) for original code
- [Joshua Morse](https://github.com/joshuamorse/) for initial code extraction
- [Gábor Fási](https://github.com/maerlyn/) for extended maintenance

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 73.3% 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 ~354 days

Total

4

Last Release

3618d ago

Major Versions

v1.0.2 → v2.02016-06-15

PHP version history (2 changes)v1.0PHP &gt;=5.3.2

v2.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21580?v=4)[Gábor Fási](/maintainers/maerlyn)[@maerlyn](https://github.com/maerlyn)

---

Top Contributors

[![ubermuda](https://avatars.githubusercontent.com/u/10758?v=4)](https://github.com/ubermuda "ubermuda (11 commits)")[![maerlyn](https://avatars.githubusercontent.com/u/21580?v=4)](https://github.com/maerlyn "maerlyn (3 commits)")[![shamalt](https://avatars.githubusercontent.com/u/1786555?v=4)](https://github.com/shamalt "shamalt (1 commits)")

---

Tags

doctrine2repositorysilex

### Embed Badge

![Health badge](/badges/insolis-repository-service-provider/health.svg)

```
[![Health](https://phpackages.com/badges/insolis-repository-service-provider/health.svg)](https://phpackages.com/packages/insolis-repository-service-provider)
```

###  Alternatives

[sonata-project/doctrine-extensions

Doctrine2 behavioral extensions

26921.9M66](/packages/sonata-project-doctrine-extensions)[dbtlr/silex-doctrine-migrations

Doctrine migration service provider for Silex

1123.8k1](/packages/dbtlr-silex-doctrine-migrations)[symlex/doctrine-active-record

Object-oriented CRUD for Doctrine DBAL

308.7k2](/packages/symlex-doctrine-active-record)[lastzero/doctrine-active-record

Object-oriented CRUD for Doctrine DBAL

306.0k](/packages/lastzero-doctrine-active-record)[nilportugues/sql-repository

SQL Repository implementation

361.9k](/packages/nilportugues-sql-repository)

PHPackages © 2026

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