zhortein/ovh-api-bundle
Composer 安装命令:
composer require zhortein/ovh-api-bundle
包简介
A comprehensive Symfony 7+ bundle for OVH SDK integration.
关键字:
README 文档
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.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-25