symfonyboot/symfonyboot-bundle

This package is abandoned and no longer maintained. The author suggests using the https://github.com/silasyudi/restboot-bundle package instead.

Bundle of annotations to make it easier and faster to develop Rest APIs with Symfony.

Installs: 255

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

v3.0.0 2023-06-29 03:06 UTC

This package is auto-updated.

Last update: 2023-06-29 03:07:23 UTC


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 🇧🇷