sgdf/intranet-api-client
Composer 安装命令:
composer require sgdf/intranet-api-client
包简介
PHP client for the SGDF Intranet API.
README 文档
README
A PHP 8.2+ Composer library that wraps the SGDF Intranet API behind a small, typed, PSR-18/PSR-17-based HTTP client. Guzzle is the default transport but any PSR-18 client can be injected.
Installation
composer install
Authentication is handled for you: the client obtains an OAuth2 access token
(client-credentials grant) from Keycloak, caches it until it expires, and sends it
— together with the idAppelant caller header — on every request. Responses are
returned as typed model objects; the API's { data, errors } envelope is unwrapped
automatically and business errors are raised as ApiErrorException.
Quick start
Qualification:
baseUri: 'https://test-api-sgdf-qual.intrassoc.com'
tokenUrl: 'https://auth.sgdf-qual.intrassoc.com/auth/realms/sgdf_qualification/protocol/openid-connect/token'
Production:
baseUri: 'https://intranetapi.sgdf.fr'
tokenUrl: 'https://auth.sgdf.fr/auth/realms/sgdf_production/protocol/openid-connect/token'
Example:
use Sgdf\IntranetApi\Client\Configuration;
use Sgdf\IntranetApi\Client\IntranetApiClient;
$client = IntranetApiClient::create(new Configuration(
baseUri: 'https://test-api-sgdf-qual.intrassoc.com',
tokenUrl: 'https://auth.sgdf-qual.intrassoc.com/auth/realms/sgdf_qualification/protocol/openid-connect/token',
oauthClientId: 'my-client-id',
clientSecret: 'my-client-secret',
idAppelant: 'my-calling-id',
));
// Typed access through resource groups:
foreach ($client->configuration()->listCivilites() as $civilite) {
echo $civilite->getId() . ' → ' . $civilite->getLibelle() . "\n";
}
You can also inject your own PSR-18 client, PSR-17 factories and token provider for full control:
$client = new IntranetApiClient($httpClient, $requestFactory, $streamFactory, $configuration, $tokenProvider);
Configuration & credentials
Local access is read from a git-ignored .env file. Copy the template:
cp .env.dist .env
# then fill in the base URI, token URL, OAuth client id/secret and idAppelant
Never commit .env.
Development
composer test # run the offline unit test suite
composer qa # style check + static analysis + tests
Integration tests hit the real API and are skipped unless
SGDF_API_INTEGRATION_TESTS=1 and SGDF_API_BASE_URI are set in .env.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-07-12