composer req rfrommherz/api
- config/bundles.php: Add new bundle to bundles.php
Rf\ApiBundle\JwtBundle::class => ['dev' => true],
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://...",
}'