ecphp/cns-client-bundle
Symfony bundle to send notifications via the EU Corporate Notification System (CNS). Provides a simple client to deliver GDPR-compliant emails to internal and external users. Requires PHP 7.4+ and Symfony 5.3+.
laravel/symfony-bundle). If the Laravel app already integrates Symfony components (e.g., HTTP clients, dependency injection), this package can be leveraged with minimal abstraction.X-CNS-CS-Auth-Key).HttpClient (via symfony/http-client) for HTTP requests, which Laravel can consume via Guzzle or Symfony HttpClient facade.Laravel\SymfonyBridge\ServiceProvider).symfony/http-client-contracts, which Laravel can satisfy via symfony/http-client or guzzlehttp/guzzle.config/packages/, which Laravel can mimic via config/cns.php or merge into existing Symfony config.symfony/http-client-contracts may conflict).X-CNS-CS-Auth-Key), which must be securely managed (e.g., via Laravel’s env() or Symfony’s ParameterBag).Storage) may need adaptation for Symfony’s UploadedFile interface.CnsClient facade to abstract Symfony’s NotificationService?X-CNS-CS-Auth-Key be stored/rotated (e.g., Laravel’s env(), Vault, or Symfony’s ParameterBag)?Storage (e.g., S3, local) integrate with Symfony’s UploadedFile for attachments?Log)?laravel/symfony-bundle to integrate Symfony services (e.g., HttpClient, NotificationService) into Laravel’s DI container.HttpClient) and wrap them in Laravel services.symfony/http-client-guzzle adapter, but adds complexity.NotificationService to a Laravel service provider:
// app/Providers/CnsServiceProvider.php
public function register()
{
$this->app->singleton('cns.notification', function ($app) {
return new \ECPHP\CnsClientBundle\Service\NotificationService(
$app['config']['cns.api_key'],
$app['symfony.http_client']
);
});
}
composer require ecphp/cns-client-bundle symfony/http-client symfony/options-resolver
HttpClient:
// config/app.php
'providers' => [
Laravel\SymfonyBridge\ServiceProvider::class,
],
config/cns.php to mirror Symfony’s bundle config:
return [
'api_key' => env('CNS_API_KEY'),
'endpoint' => env('CNS_ENDPOINT', 'https://api.cns.example.com'),
'debug' => env('APP_DEBUG'),
];
NotificationService:
// app/Services/CnsNotificationService.php
class CnsNotificationService
{
public function __construct(private NotificationService $symfonyService) {}
public function send(Notification $notification)
{
return $this->symfonyService->send($notification);
}
}
HttpClient mocking or Symfony’s MockHttpClient.config() helper to replace Symfony’s ParameterBag.Events or manual dispatch.Log facade.Mail::send()) with CNS for GDPR-compliant paths.Mail if CNS fails).symfony/http-client-contracts for breaking changes (e.g., Symfony 6+ compatibility).composer.json to avoid unexpected updates.config/cns.php to avoid Symfony-specific files.env() or a secrets manager (e.g., HashiCorp Vault).Debug component for HTTP request/response inspection.Log::debug()) for CNS interactions.CnsApiException).try {
$this->cnsService->send($notification);
} catch (\Symfony\Contracts\HttpClient\Exception\ClientException $e) {
throw new CnsApiException("Invalid recipient: " . $e->getMessage());
}
Notification objects in Laravel.HttpClient supports this).Cache facade.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| CNS API downtime | No notifications sent | Fallback to Laravel’s Mail or queue for retry. |
| Invalid API key | All requests fail | Automated key rotation + alerting (e.g., Laravel Horizon). |
| Rate limiting | Throttled requests | Implement retry logic with jitter (Symfony’s ` |
How can I help you explore Laravel packages today?