silasyudi/restboot-bundle
Composer 安装命令:
composer require silasyudi/restboot-bundle
包简介
Bundle of annotations to make it easier and faster to develop Rest APIs with Symfony.
README 文档
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 🇧🇷
统计信息
- 总下载量: 1.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-14