PHP code example of tandrewcl / api-request-convert

1. Go to this page and download the library: Download tandrewcl/api-request-convert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tandrewcl / api-request-convert example snippets


...
use tandrewcl\ApiRequestConvertBundle\DTO\ResolvableInputDTOInterface;
...

class LoginDTO implements ResolvableInputDTOInterface
{
    #[Assert\NotBlank]
    #[Assert\Length(max: 16)]
    public ?string $login = null;

    #[Assert\NotBlank]
    #[Assert\Length(max: 16)]
    public ?string $password = null;

    public function handleRequest(Request $request): void
    {
        $params = $request->request->all();
        $this->login = $params['login'] ?? null;
        $this->password = $params['password'] ?? null;
    }
}

...
use tandrewcl\ApiResponseConvertBundle\Handler\ResponseHandler;
...

class FooController
{
    public function loginAction(LoginDTO $loginDTO): Response
    {
        ...
        $authResult = $authService->auth($loginDTO->login, $loginDTO->password);
        ...
    }