zhortein / ovh-api-bundle
A comprehensive Symfony 7+ bundle for OVH SDK integration.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Type:symfony-bundle
Requires
- php: >=8.3
- ovh/ovh: ^v3.5.0
- symfony/config: ~7.0
- symfony/dependency-injection: ~7.0
- symfony/http-kernel: ~7.0
- symfony/yaml: ~7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.75.0
- phpstan/phpstan: ^2.1
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/php-code-coverage: ^12.3.1
- phpunit/phpunit: ^12.2.5
- roave/security-advisories: dev-latest
- symfony/framework-bundle: ^7.0
- symfony/phpunit-bridge: ^7.3
- symfony/test-pack: ^1.0
- symfony/twig-bundle: ^7.0
This package is not auto-updated.
Last update: 2025-08-26 06:06:53 UTC
README
Un bundle Symfony 7+ complet pour l'intégration du SDK OVH. Ce bundle fournit un wrapper autour du SDK PHP officiel d'OVH, facilitant l'intégration des fonctionnalités de l'API OVH dans les applications Symfony.
🚀 Fonctionnalités
- ✅ Wrapper simple et élégant autour du SDK OVH officiel
- ✅ Configuration via YAML avec support des variables d'environnement
- ✅ Injection de dépendances native Symfony
- ✅ Support complet de PHPStan (niveau max)
- ✅ Tests unitaires et d'intégration inclus
- ✅ Documentation complète avec exemples
- ✅ Gestion d'erreurs robuste
- ✅ Compatible Symfony 7+ et PHP 8.3+
📦 Installation
Via Composer
composer require zhortein/ovh-api-bundle
Activation du bundle
Ajoutez le bundle dans votre fichier config/bundles.php
:
<?php return [ // ... Zhortein\OvhApiBundle\ZhorteinOvhApiBundle::class => ['all' => true], ];
⚙️ Configuration
1. Configuration du bundle
Créez le fichier config/packages/zhortein_ovh_api.yaml
:
zhortein_ovh_api: application_key: '%env(OVH_APPLICATION_KEY)%' application_secret: '%env(OVH_APPLICATION_SECRET)%' endpoint_name: 'ovh-eu' # Optionnel, par défaut 'ovh-eu' consumer_key: '%env(OVH_CONSUMER_KEY)%'
2. Variables d'environnement
Ajoutez vos clés API dans votre fichier .env
:
OVH_APPLICATION_KEY=your_application_key OVH_APPLICATION_SECRET=your_application_secret OVH_CONSUMER_KEY=your_consumer_key
🔧 Utilisation
Injection du service
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Annotation\Route; use Zhortein\OvhApiBundle\Service\OvhApiService; class ApiController extends AbstractController { public function __construct( private OvhApiService $ovhApiService ) { } #[Route('/api/me', name: 'api_me')] public function getMe(): JsonResponse { try { $me = $this->ovhApiService->get('/me'); return $this->json($me); } catch (\Exception $e) { return $this->json(['error' => $e->getMessage()], 500); } } }
Méthodes disponibles
// Requêtes HTTP $ovhApiService->get('/me'); $ovhApiService->post('/domain', $data); $ovhApiService->put('/domain/example.com', $data); $ovhApiService->delete('/domain/example.com'); // Utilitaires $timestamp = $ovhApiService->getTime(); $credentials = $ovhApiService->requestCredentials($accessRules, $redirection); // Gestion des clés $consumerKey = $ovhApiService->getConsumerKey(); $ovhApiService->setConsumerKey($newConsumerKey); // Accès direct au SDK OVH (pour usage avancé) $api = $ovhApiService->getApi();
📚 Documentation
🧪 Tests
# Tests unitaires make test-unit # Tous les tests make test # Analyse statique make phpstan # Style de code make csfixer
📄 Licence
Ce projet est sous licence MIT. Voir le fichier LICENSE pour plus de détails.