rfrommherz / api
Symfony api simplifier
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.0
- doctrine/annotations: ^1.13
- ramsey/uuid: ^4.2
- symfony/serializer: 5.3.*
- symfony/validator: 5.3.*
- symfony/yaml: 5.3.*
This package is auto-updated.
Last update: 2025-04-06 05:19:48 UTC
README
Installation
composer req rfrommherz/api
- config/bundles.php: Add new bundle to bundles.php
Rf\ApiBundle\JwtBundle::class => ['dev' => true],
Usage
ApiDto
ApiDto's can be used as parameters in your controllers. To enable the support for this, your class must extend ApiDto. Each ApiDto is passed to the symfony validator, which enables the support for validation annotations.
use Rf\ApiBundle\Dto\ApiDto; use Symfony\Component\Validator\Constraints as Assert; class Fetch extends ApiDto { /** * @Assert\NotBlank * @Assert\Url * @var string */ private string $repositoryUrl;
Arguments will be automatically resolved and can be passed as controller arguments.
public function index(Fetch $fetch): Response { ... }
curl --location --request GET 'http://localhost/fetch' \ --header 'Content-Type: application/json' \ --data-raw '{ "repositoryUrl": "http://...", }'