vaneves/collection-extractor

Doctrine 集合提取器

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

This package is not auto-updated.

Last update: 2024-09-18 10:42:49 UTC


README

安装

通过 Composer

composer require vaneves/collection-extractor

用法

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