sgdf/intranet-api-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-07-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固