latvijas-talrunis / api-auth-client-maker
An API Client Maker For Specific Purpose
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/latvijas-talrunis/api-auth-client-maker
Requires
- symfony/http-client: ^6.2
This package is not auto-updated.
Last update: 2025-11-01 23:04:39 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();
}