grzegorz-jamroz/sf-api-bundle

There is no license information available for the latest version (7.0.3) of this package.

Bundle provides basic features for Symfony Api.

Installs: 116

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/grzegorz-jamroz/sf-api-bundle

7.0.3 2025-10-27 12:33 UTC

This package is auto-updated.

Last update: 2025-10-27 13:30:20 UTC


README

Bundle provides basic features for Symfony Api

Code Coverage Code Coverage Release Version Read License

Installation

composer require grzegorz-jamroz/sf-api-bundle

Development with Docker

Build and run the containers:

docker compose up -d

Copy vendor folder from container to host

docker compose cp app:/app/vendor ./vendor

Run static analysis

docker compose exec app bin/fix

Run tests

docker compose exec app bin/test

Run single test file:

docker compose exec app vendor/bin/phpunit --filter <testMethodName> <path/to/TestFile.php>
docker compose exec app vendor/bin/phpunit --filter testShouldReturnExpectedFloat tests/Unit/TransformNumeric/ToFloatTest.php

Enable xdebug

docker compose exec app xdebug on

Disable xdebug

docker compose exec app xdebug off

Run coverage report

  1. Enable xdebug
  2. Run:
docker compose exec app bin/coverage

Usage

Add to your config/routes.yaml file

# config/routes.yaml

ifrost_api:
    resource: ../src/Action/
    type: ifrost_api

Default config

You can add config/packages/ifrost_api.yaml in your project to enable/disable some features if not necessary

# config/packages/ifrost_api.yaml
# You can enable/disable some features if not necessary
ifrost_api:
  api_request: true
  exception_listener: false

and from now you can add attribute Symfony\Component\Routing\Annotation\Route to your Action class for example:

<?php
declare(strict_types=1);

namespace App\Action\Product;

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

#[Route('/product/promotion', name: 'product_promotion', methods: ['POST'])]
class PromoteAction
{
    public function __invoke(): Response
    {
        return new JsonResponse(['message' => 'product promotion']);
    }
}

and when you run bin/console debug:router you will see:

 ------------------- -------- -------- ------ -----------------------------------
  Name                Method   Scheme   Host   Path
 ------------------- -------- -------- ------ -----------------------------------
  product_promotion   POST     ANY      ANY    /product/promotion
 ------------------- -------- -------- ------ -----------------------------------