Download the PHP package batenburg/response-factory-bundle without Composer
On this page you can find all versions of the php package batenburg/response-factory-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download batenburg/response-factory-bundle
More information about batenburg/response-factory-bundle
Files in batenburg/response-factory-bundle
Package response-factory-bundle
Short Description A response factory bundle, to clean your controller code.
License MIT
Informations about the package response-factory-bundle
Response factory bundle
Response factory for the Symfony Framework.
What is Response factory Bundle?
The response factory bundle is a bundle with a response factory, to make clean code in your Symfony controllers. It is inspired by the response factory from laravel.
For who?
Everybody who loves clean code.
Installation
Install with composer:
Register the bundle, add the following line to config/bundles.php
:
Usage
After the installation is completed, the ResponseFactoryInterface can be resolved by dependency injection. Or through the container. It is highly recommended to use dependency injection.
An example::
<?php
namespace App\Controller;
use Batenburg\ResponseFactoryBundle\Component\HttpFoundation\Contract\ResponseFactoryInterface;
use Batenburg\ResponseFactoryBundle\Component\HttpFoundation\Response;
class BrandController
{
/**
* @var ResponseFactoryInterface
*/
private $responseFactory;
/**
* @param ResponseFactoryInterface $responseFactory
*/
public function __construct(ResponseFactoryInterface $responseFactory)
{
$this->responseFactory = $responseFactory;
}
/**
* @return Response
*/
public function create(): Response
{
return $this->responseFactory->render('brand/create.html.twig');
}
}
Note
To use the constructor injection, you must register the controller in you yaml file::
App\Controller\BrandController:
tags: ['controller.service_arguments']
arguments:
$responseFactory: '@batenburg.response_factory_bundle.component.http_foundation.response_factory'
Using dependency injection on a method, will resolved automatically.
License
The Caching Bundle is open-sourced software licensed under the MIT license.
All versions of response-factory-bundle with dependencies
symfony/dependency-injection Version ^4.3 || ^4.4 || ^5.0 || ^5.1
symfony/framework-bundle Version ^4.3 || ^4.4 || ^5.0 || ^5.1
symfony/twig-bundle Version ^4.3 || ^4.4 || ^5.0 || ^5.1
twig/twig Version ^2.1 || ^3.0