PHP code example of vaneves / collection-extractor
1. Go to this page and download the library: Download vaneves/collection-extractor library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vaneves / collection-extractor example snippets
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();