latvijas-talrunis / api-auth-client-maker
An API Client Maker For Specific Purpose
dev-main
2023-02-10 12:10 UTC
Requires
- symfony/http-client: ^6.2
This package is not auto-updated.
Last update: 2025-06-28 21:22:46 UTC
README
from LT/Utils
How to set up in symfony:
- Install with
composer require latvijas-talrunis/api-auth-client-maker
In the case of your project not being able to find the ClientMaker. This might help:
composer dump-autoload
- Update your project's
services:
LT\Utils\ApiClientMaker\ClientMaker:
arguments:
$authServiceUrl: '%env(string:AUTH_SERVICE_URL)%'
$authServiceUser: '%env(string:AUTH_SERVICE_USER)%'
$authServicePassword: '%env(string:AUTH_SERVICE_PASSWORD)%'
- Update your .env file with these 3 variables
AUTH_SERVICE_URL=http://url.to.the.auth.service
AUTH_SERVICE_USER=root
AUTH_SERVICE_PASSWORD=
- And for the controller:
It needs a class property in which to keep the instantiated ClientMaker
public $clientMaker;
It needs to be set up in the clients constructor
public function __construct(ApiClientMaker $serviceMediatorClientMaker){
$this->clientMaker = $serviceMediatorClientMaker;
}
And then it will be available in every method of this particular controller
#[Route('/test')]
public function index(): Response
{
// authorized symfony http client
$client = $this->clientMaker->getClient();
}