knplabs / rad-view-renderer
Installs: 43 907
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 31
Forks: 2
Open Issues: 0
Requires
- php: ~7.0
- symfony/config: ~2.8||~3.0
- symfony/dependency-injection: ~2.8||~3.0
- symfony/framework-bundle: ~2.8||~3.0
- symfony/http-kernel: ~2.8||~3.0
- symfony/templating: ~2.8||~3.0
Requires (Dev)
- jms/serializer: ~0.11|^1.0
- phpspec/phpspec: ~2.4
Suggests
- jms/serializer: Needed if you want to render JSON responses.
This package is auto-updated.
Last update: 2022-09-23 13:36:00 UTC
README
Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to hello@knplabs.com.
Rad view renderer
Allow to guess a view when the controller does not return a Response.
Installation
Install the library:
$ composer require knplabs/rad-view-renderer
If you are using Symfony, add the bundle inside your AppKernel.php
:
$bundles = array( // ... new Knp\Rad\ViewRenderer\Bundle\ViewRendererBundle(), );
Usage
Let's take the following controller:
namespace App\Controller; class TestController { public function someAction() { return ['foo' => 'bar']; } }
By default the rad view renderer will take a look of the request content type in order to guess wich kind of render it will use. It exists many kind of renderer that can display many content types.
You can disable some native renderers using the renderers
parameter in your config.yml
:
knp_rad_view_renderer: renderers: [controller, twig]
The twig renderer
One of the most useful renderer, it takes the controller class in order to guess the template to display. For example:
App\Controller\TestController::someAction => @App/Resources/views/Test/some.%format%.twig