vaneves/collection-extractor

Doctrine Collection Extractor

v0.0.1 2015-09-23 16:59 UTC

This package is not auto-updated.

Last update: 2024-05-01 08:55:52 UTC


README

Installing

Via Composer

composer require vaneves/collection-extractor

Usage

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();