定制 silasyudi/restboot-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Tests Maintainability Test Coverage

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固