Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ovh Bundle Laravel Package

aldaflux/ovh-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Bundle

    composer require aldaflux/ovh-bundle
    

    Ensure your project uses Symfony 7.1+ (per composer.json).

  2. Configure Credentials Add OVH API keys to .env:

    OVH_APPLICATION_KEY=your_app_key
    OVH_APPLICATION_SECRET=your_app_secret
    OVH_CONSUMER_KEY=your_consumer_key
    

    Update config/packages/aldaflux_ovh.yaml with the required endpoint (e.g., "ovh-eu").

  3. First Use Case: Fetching VPS Info Inject the OvhClient service (auto-registered by the bundle) and call an API method:

    use AldaFlux\OvhBundle\Service\OvhClient;
    
    public function getVpsInfo(OvhClient $ovhClient)
    {
        $vps = $ovhClient->get('/vps', ['serviceName' => 'your_vps_service_name']);
        return json_decode($vps->getBody(), true);
    }
    

Implementation Patterns

Workflows

  1. API Calls with Authentication The bundle wraps the ovh/ovh library, so leverage its methods:

    $ovhClient->post('/vps/boot', ['serviceName' => 'vps123']);
    $ovhClient->delete('/domain/zone/example.com/record', ['subDomain' => 'www']);
    
  2. Handling Responses Use the OvhResponse object to access data:

    $response = $ovhClient->get('/domain/zone/example.com/record');
    if ($response->isSuccess()) {
        $records = json_decode($response->getBody(), true);
    } else {
        throw new \RuntimeException($response->getErrorMessage());
    }
    
  3. Default Configuration Use the optional default config (e.g., ip, domain) to avoid repeating values:

    aldaflux_ovh:
        default:
            domain: '%env(resolve:DEFAULT_DOMAIN)%'
    

    Access via:

    $ovhClient->get('/domain/zone', ['domain' => $ovhClient->getConfig('domain')]);
    
  4. Service Integration Bind the OvhClient to a service in your controller/repo:

    public function __construct(private OvhClient $ovhClient) {}
    

Integration Tips

  • Error Handling: Wrap API calls in try-catch blocks to handle OVH-specific exceptions (e.g., Ovh\Exception\OvhException).
  • Rate Limiting: Respect OVH’s rate limits by adding delays between calls.
  • Logging: Log API responses for debugging:
    $this->logger->debug('OVH Response', ['body' => $response->getBody()]);
    

Gotchas and Tips

Pitfalls

  1. Endpoint Mismatch

    • Issue: Using the wrong endpoint (e.g., ovh-eu vs. ovh-us) will fail silently or return incorrect data.
    • Fix: Verify the endpoint in aldaflux_ovh.yaml matches your OVH region.
  2. Missing Environment Variables

    • Issue: Unset .env variables (e.g., OVH_APPLICATION_KEY) will throw ParameterNotFoundException.
    • Fix: Validate .env with:
      php bin/console debug:config aldaflux_ovh
      
  3. Deprecated OVH API Methods

    • Issue: The underlying ovh/ovh library may not support newer OVH API v3 endpoints.
    • Fix: Check the OVH API docs and update the bundle or fork it if needed.
  4. Caching Responses

    • Issue: Frequent API calls (e.g., checking DNS records) may hit rate limits.
    • Fix: Cache responses in Symfony’s cache system:
      $cache = $this->container->get('cache.app');
      $cached = $cache->get('ovh_dns_records', function() use ($ovhClient) {
          return $ovhClient->get('/domain/zone/example.com/record')->getBody();
      });
      

Debugging

  • Enable Debug Mode: Set OVH_DEBUG=true in .env to log raw API requests/responses.
  • Check Headers: Use dd($response->getHeaders()) to inspect HTTP headers for errors (e.g., X-Ovh-Api-Auth-Failure).

Extension Points

  1. Custom Services Extend the bundle by creating a service that wraps OvhClient:

    # config/services.yaml
    services:
        App\Service\OvhDnsManager:
            arguments:
                $ovhClient: '@aldaflux_ovh.client'
    
  2. Event Listeners Listen for OVH API events (e.g., after a DNS update):

    use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
    
    #[AsEventListener(event: 'aldaflux_ovh.api.response', method: 'onOvhResponse')]
    public function onOvhResponse(OvhResponseEvent $event) {
        if ($event->getResponse()->getPath() === '/domain/zone/...') {
            // Handle DNS update
        }
    }
    
  3. Testing Mock the OvhClient in tests:

    $mockClient = $this->createMock(OvhClient::class);
    $mockClient->method('get')->willReturn(new OvhResponse(200, '{"status":"ok"}'));
    $this->container->set('aldaflux_ovh.client', $mockClient);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky