Installation Add the bundle via Composer:
composer require aih/aih-bundle
Enable it in config/bundles.php:
return [
// ...
AlpesIsereHabitat\AihBundle\AihBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console config:dump-reference aih
Override settings in config/packages/aih.yaml (e.g., API endpoints, credentials).
First Use Case Fetch a user's city via MS Graph (most common entry point):
use AlpesIsereHabitat\AihBundle\Service\MsGraphService;
class MyController extends AbstractController {
public function getUserCity(MsGraphService $msGraph): Response {
$city = $msGraph->getUserCity('user@domain.com');
return $this->json($city);
}
}
MS Graph Integration
MsGraphService.php bin/console cache:clear
MicrosoftGraphException (e.g., auth failures).Communication Management
$communications = $this->get('aih.communication_service')->getCommunications();
$commIds = [1, 2, 3];
$communications = $this->get('aih.communication_service')->getCommunicationsByIds($commIds);
SMS API
$remainingSms = $this->get('aih.sms_service')->getRemainingSms();
Health Checks
/healthcheck (auto-registered). Use for monitoring:
$this->get('aih.healthcheck_service')->check();
MsGraphService, CommunicationService).aih.yaml for custom API endpoints or timeouts:
aih:
ms_graph:
base_uri: 'https://your-graph-endpoint.com'
timeout: 30
cmt_client:
api_key: '%env(AIH_CMT_API_KEY)%'
GraphQLService (see return ?array fix in v0.1.7).Symfony Version Mismatch
composer.json for required Symfony versions.Caching Quirks
aih_. Clear manually if stale data persists:
php bin/console cache:pool:clear cache.app
aih:
cache_ttl: 7200 # 2 hours
MS Graph Auth
MicrosoftGraphException for expired tokens. Implement a retry logic or refresh token flow.?string (v0.1.3). Cast explicitly if needed:
$department = $msGraph->getUserDepartment('user@domain.com') ?? 'N/A';
Deprecated Extensions
aih.communication_service).monolog:
handlers:
main:
level: debug
/healthcheck endpoint to verify bundle readiness:
curl http://localhost:8000/healthcheck
Custom Clients
HappilyApiGdClient or CmtClient for additional APIs. Example:
class CustomClient extends HappilyApiGdClient {
public function customMethod() { ... }
}
services:
aih.custom_client:
class: App\Service\CustomClient
arguments: ['@aih.http_client']
GraphQL Extensions
GraphQLService by extending the base class:
class CustomGraphQLService extends \AlpesIsereHabitat\AihBundle\Service\GraphQLService {
protected function getCustomQuery(): string { ... }
}
Backup Restoration
backup:restore command (v0.3.0) for database backups:
php bin/console aih:backup:restore /path/to/backup.sql
How can I help you explore Laravel packages today?