An open API service indexing awesome lists of open source software.

https://github.com/vaneves/collection-extractor

Doctrine Collection Extractor
https://github.com/vaneves/collection-extractor

Last synced: about 1 month ago
JSON representation

Doctrine Collection Extractor

Awesome Lists containing this project

README

          

# Doctrine Collection Extractor

## Installing

Via Composer

```
composer require vaneves/collection-extractor
```

## Usage

``` php

use Silex\Application;
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator;
use Vaneves\Doctrine\CollectionExtractor;

$app = new Application();
$app['debug'] = true;

$app->get('/blog/posts', function () use ($app) {

$em = $app['orm.em'];

$results = $em->getRepository('App\Entities\Post')->findAll();

$hydrator = new CollectionExtractor(new DoctrineHydrator($em));

return $app->json($hydrator->extract($results));
});

$app->run();

```