PHPackages                             xepan/digitalocean-v2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. xepan/digitalocean-v2

ActiveLibrary[API Development](/categories/api)

xepan/digitalocean-v2
=====================

DigitalOcean API v2 PHP 5.4+ library curtsy: toin0u/digitalocean-v2

2.2.0(9y ago)11.2kMITPHPPHP &gt;=5.4.0

Since Jul 4Pushed 8y ago2 watchersCompare

[ Source](https://github.com/xepan/DigitalOceanV2)[ Packagist](https://packagist.org/packages/xepan/digitalocean-v2)[ Docs](https://github.com/toin0u/DigitalOceanV2)[ RSS](/packages/xepan-digitalocean-v2/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (19)Used By (0)

DigitalOcean V2
===============

[](#digitalocean-v2)

Let's consume the [DigitalOcean API V2](https://developers.digitalocean.com/v2/) ([issues](https://github.com/digitalocean/api-v2/issues) / [changelog](https://developers.digitalocean.com/documentation/changelog/)) :)

[![Build Status](https://camo.githubusercontent.com/be9e1fb3c2eea93b731ba88a1ac369cc887422102d3b8d56471a8c0ddd5bcf27/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f746f696e30752f4469676974616c4f6365616e56322e706e67)](http://travis-ci.org/toin0u/DigitalOceanV2)[![Latest Stable Version](https://camo.githubusercontent.com/802c08850914e02d03995a46d6970fc20b7c88bd14f6b8bec5f4c6adac012186/68747470733a2f2f706f7365722e707567782e6f72672f746f696e30752f6469676974616c6f6365616e2d76322f762f737461626c652e737667)](https://packagist.org/packages/toin0u/digitalocean-v2)[![Total Downloads](https://camo.githubusercontent.com/7efdadd8c7e3a14c87722cd7dc71f9a2d7912b3ab83eddb49872da030d4f16e7/68747470733a2f2f706f7365722e707567782e6f72672f746f696e30752f6469676974616c6f6365616e2d76322f646f776e6c6f6164732e706e67)](https://packagist.org/packages/toin0u/digitalocean-v2)[![SensioLabsInsight](https://camo.githubusercontent.com/693f2c30d9d827f76666b6f0dcba30f361463aaad50f7d3a59511c9dea8df42d/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35623465616337652d633833622d343931332d383665312d3732393530383231373537612f6d696e692e706e67)](https://insight.sensiolabs.com/projects/5b4eac7e-c83b-4913-86e1-72950821757a)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c86f157744b7af4fbc7ced166752d029ac3df6e735c023a73d8a2f33852f00bf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746f696e30752f4469676974616c4f6365616e56322f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/toin0u/DigitalOceanV2/?branch=master)[![License](https://camo.githubusercontent.com/04bcd7b7cd1bf2e9f68bfa55feebe8a698c323d8fdf9be30bc70427ff0a88f32/68747470733a2f2f706f7365722e707567782e6f72672f746f696e30752f6469676974616c6f6365616e2d76322f6c6963656e73652e737667)](https://packagist.org/packages/toin0u/digitalocean-v2)

Installation
------------

[](#installation)

This library can be found on [Packagist](https://packagist.org/packages/toin0u/digitalocean-v2). The recommended way to install this is through [composer](http://getcomposer.org).

Run these commands to install composer, the library and its dependencies:

```
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require toin0u/digitalocean-v2:~2.0
```

You then need to install **one** of the following:

```
$ php composer.phar require kriswallsmith/buzz:~0.10
$ php composer.phar require guzzle/guzzle:~3.7
$ php composer.phar require guzzlehttp/guzzle:~5.0
$ php composer.phar require guzzlehttp/guzzle:~6.0
```

Or edit `composer.json` and add:

```
{
    "require": {
        "toin0u/digitalocean-v2": "~2.0"
    }
}
```

And then add **one** of the following:

```
{
    "require": {
        "kriswallsmith/buzz": "~0.10",
        "guzzle/guzzle": "~3.7",
        "guzzlehttp/guzzle": "~5.0",
        "guzzlehttp/guzzle": "~6.0"
    }
}
```

### Using Laravel?

[](#using-laravel)

[Laravel DigitalOcean](https://github.com/GrahamCampbell/Laravel-DigitalOcean) by [Graham Campbell](https://github.com/GrahamCampbell) might interest you.

```
{
    "require": {
        "graham-campbell/digitalocean": "~3.0"
    }
}
```

### Using Symfony2?

[](#using-symfony2)

For Symfony2 users, there is no need to create separate bundle (But you could if you wanted to).Just install `toin0u/digitalocean-v2` via composer and define it as a service. For example:

```
# YourBundle/Resources/config/services.yml
parameters:
    do.class.factory: DigitalOceanV2\DigitalOceanV2
    do.class.adapter: DigitalOceanV2\Adapter\GuzzleAdapter
    ....

services:
    do.adapter:
        class: %do.class.adapter%
        public: false
        arguments: [api_secret]

    do.factory:
        class: %do.class.factory%
        arguments: [@do.adapter]

    ....
```

Now you can use in container.

```
$droplet = $this->container->get('do.factory')->droplet();
```

Or you could define your service api one by one using a class factory.

```
parameters:
    ....
    do.class.api.droplet: DigitalOceanV2\Api\Droplet
    do.class.api.action: DigitalOceanV2\Api\Action
    do.class.api.domain: ...

services:
    ....

    do.droplet:
        class: %do.class.api.droplet%
        factory_service: do.factory
        factory_method: droplet

    do.action:
        class: %do.class.api.action%
        factory_service: do.factory
        factory_method: action

    do.domain:
        ....
```

And now you can use it in the container as

```
$droplets = $this->container->get('do.droplet')->getAll();
```

> This is helpful for a child of `Symfony\Bundle\FrameworkBundle\Controller\Controller` user to use by `$this->get('do.droplet')->getAll()`

Adapter
-------

[](#adapter)

We provide a simple `BuzzAdapter` which (at the moment) can be tweaked by injecting your own `Browser`and `ListenerInterface`. By default a `Curl` client will be injected in `Browser` and the `BuzzOAuthListener`will be used.

To wrap your own response message, please inject your own `ExceptionInterface` if needed (see `DigitalOceanV2\Exception\ResponseException` for more info).

If you use Guzzle, you can inject your own client to our `GuzzleAdapter`.

You can also build your own adapter by extending `AbstractAdapter` and implementing `AdapterInterface`.

API documentation
-----------------

[](#api-documentation)

The API documentation is available [here](https://cdn.rawgit.com/toin0u/DigitalOceanV2/master/documentation/index.html) and generated using [phpDocumentor](https://www.phpdoc.org/)

Example
-------

[](#example)

```
