symfonyboot / symfonyboot-bundle
Bundle of annotations to make it easier and faster to develop Rest APIs with Symfony.
Installs: 257
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- ext-ctype: *
- ext-iconv: *
- ext-json: *
- doctrine/annotations: ^2.0
- doctrine/doctrine-bundle: ^2
- doctrine/orm: ^2
- jms/serializer: ^3.26
- symfony/flex: ^1.3
- symfony/framework-bundle: ^4.4 | ^5
- symfony/property-access: ^4.4 | ^5
- symfony/property-info: ^4.4 | ^5
- symfony/yaml: ^4.4 | ^5
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Symfony package to speed up the development of rest apis.
Summary
Language / Idioma
Leia a versão em português 🇧🇷 aqui.
Instalation
composer require silasyudi/restboot-bundle
Requirements
- PHP 7.4+
- Composer
- Symfony 4.4+ / 5+
- Doctrine 2+
Features
Convert payloads into objects in the controller methods
With @Body and @Query annotations, you can automatically convert your payloads and queries into objects in the controller methods.
Example without RestBoot:
/** * Payload converted with some serializer * @Route("/myAction", methods={"POST"}) */ public function __invoke(Request $request, SerializerInterface $serializer) { $myObject = $serializer->deserialize( $request->getContent(), MyObject::class, 'json' ); ...
Example with RestBoot:
use SilasYudi\RestBootBundle\Rest\Annotation\Body; /** * Payload converted with @Body annotation * @Route("/myAction", methods={"POST"}) * @Body("myObject") */ public function __invoke(MyObjectDTO $myObject) { ...
Easily manage the Doctrine transaction
With @Transaction annotation, you can reduce the verbosity of Doctrine transaction management.
Example without RestBoot:
/** * @Route("/myAction", methods={"POST"}) */ public function __invoke() { $connection = $this->getDoctrine()->getConnection(); try { $connection->beginTransaction(); $this->service->someAction(); if ($connection->isTransactionActive()) { $connection->commit(); } } catch (SomeException $exception) { if ($connection->isTransactionActive()) { $connection->rollback(); } } ...
Example with RestBoot:
use SilasYudi\RestBootBundle\Transaction\Annotation\Transaction; ... /** * @Route("/myAction", methods={"POST"}) * @Transaction("myConnection") */ public function __invoke() { $this->service->someAction(); ...
Documentation
English 🇺🇸
Portuguese 🇧🇷