tourze/digital-ocean-account-bundle

DO接口

0.1.0 2025-05-07 05:13 UTC

This package is auto-updated.

Last update: 2025-05-14 08:46:45 UTC


README

Latest Version Build Status Total Downloads

A Symfony bundle for integrating with DigitalOcean API, providing account management, SSH key management, and configuration services.

English | 中文

Features

  • Complete DigitalOcean API v2 integration
  • Account information management and synchronization
  • SSH key management (create, list, delete)
  • Configuration management for DigitalOcean API access
  • Doctrine ORM integration for data persistence
  • Symfony Bundle integration with autowiring support

Installation

composer require tourze/digital-ocean-account-bundle

Register the bundle in your config/bundles.php file:

<?php

return [
    // ...
    DigitalOceanAccountBundle\DigitalOceanAccountBundle::class => ['all' => true],
    // ...
];

Quick Start

Configuration

Create a configuration file at config/packages/digital_ocean_account.yaml:

digital_ocean_account:
    api_key: '%env(DIGITAL_OCEAN_API_KEY)%'

Set your DigitalOcean API key in your .env file:

DIGITAL_OCEAN_API_KEY=your_digital_ocean_api_key

Usage Examples

Accessing Account Information

<?php

use DigitalOceanAccountBundle\Service\AccountService;

class YourController
{
    public function index(AccountService $accountService)
    {
        // Get account information from DigitalOcean API
        $accountData = $accountService->getAccount();
        
        // Synchronize account information to database
        $account = $accountService->syncAccount();
        
        // Use account data...
    }
}

Managing SSH Keys

<?php

use DigitalOceanAccountBundle\Service\SSHKeyService;

class YourController
{
    public function manageSshKeys(SSHKeyService $sshKeyService)
    {
        // List all SSH keys
        $keys = $sshKeyService->listKeys();
        
        // Create a new SSH key
        $newKey = $sshKeyService->createKey('my-key-name', 'ssh-rsa AAAA...');
        
        // Delete an SSH key
        $sshKeyService->deleteKey($keyId);
    }
}

API Documentation

The bundle provides several services for interacting with the DigitalOcean API:

  • AccountService: Account information management
  • SSHKeyService: SSH key management
  • DigitalOceanConfigService: API configuration management
  • DigitalOceanClient: Low-level API client

Each service is automatically registered and can be autowired in your Symfony application.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The MIT License (MIT). Please see License File for more information.