jbuilder / jbuilder-bundle
Symfony2 bundle for JBuilder
Installs: 13 213
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=5.4
- jbuilder/common: 1.0.*
- symfony/framework-bundle: ~2.2|~3.0
Requires (Dev)
- mockery/mockery: dev-master
This package is not auto-updated.
Last update: 2024-11-18 15:44:34 UTC
README
Symfony2/Symfony3 Bundle for JBuilder
Installation
Add this lines to your composer.json:
{ "require": { "jbuilder/jbuilder-bundle": "~1.0" } }
And then execute:
$ php composer.phar install
And import a JBuilderBundle to AppKernel.php:
$bundles = array( new JBuilder\JBuilderBundle\JBuilderJBuilderBundle(), );
Usage
Insert the following code to controller:
public function indexAction() { $posts = $this->getDoctrine()->getRepository('Acme\BlogBundle\Entity\Post')->findAll(); return $this->get('jbuilder')->render('AcmeBlogBundle:Post:index.json.php', array('posts' => $posts)); }
src/Acme/BlogBundle/Resources/views/Post/index.json.php:
$json->buildArray($posts, function($json, $post) { $json->id = $post->getId(); $json->title = $post->getTitle(); });
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright
Copyright (C) 2016 Dai Akatsuka, released under the MIT License.