Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

Client

> 开发工具
Open source

DigitalOcean API v2 client for PHP

728 stars0 likes2 views
WebsiteGitHub

About

DigitalOcean API v2 client for PHP

DigitalOcean PHP API Client

We present a modern DigitalOcean API v2 client for PHP.

Check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.

Installation

This version supports PHP 8.1-8.5. To get started, simply require the project using Composer. You will also need to install packages that "provide" psr/http-client-implementation and psr/http-factory-implementation.

Standard Installation

bash
$ composer require "toin0u/digitalocean-v2:^5.1" "guzzlehttp/guzzle:^7.9.2"

Framework Integration

Laravel:

bash
$ composer require "graham-campbell/digitalocean:^11.1"

We are decoupled from any HTTP messaging client by using PSR-7, PSR-17, PSR-18, and HTTPlug. You can visit HTTPlug for library users to get more information about installing HTTPlug related packages. The framework integration graham-campbell/digitalocean is by Graham Campbell and dunglas/digital-ocean-bundle is by Kévin Dunglas.

Upgrading

If you are upgrading from version 2.3 to 3.0, or from 3.3 to 4.0, you can check out our upgrading guide. We highly recommend upgrading as soon as possible.

Examples

As of version 3.0, we will automatically discover an HTTP client to use, from what you have available. Simply create a new DigitalOcean client, provide your access token, then you're good to go:

php
authenticate('your_access_token');

Version 3.0 also has a built-in paginator, and can be used on any of the APIs which return collections. By default, the pager will internally attempt to fetch 100 entries in each request, however this can be configured by passing a 2nd parameter to the constructor. We have included an example below which will fetch all droplets:

php
// create a new result pager
$pager = new DigitalOceanV2\ResultPager($client);

// get all droplets as an array
$droplets = $pager->fetchAll($client->droplet(), 'getAll');

// get all droplets as a Generator which lazily yields
// new results as they become available
$droplets = $pager->fetchAllLazy($client->droplet(), 'getAll');

Account

php
// return the account api
$account = $client->account();

// return the Account entity
$userInformation = $account->getUserInformation();

Action

php
// return the action api
$action  = $client->action();

// return a collection of Action entity
$actions = $action->getAll();

// return the Action entity 123
$action123 = $action->getById(123);

App

…

Database

…

CDN Endpoint

…

Domain

php
// return the domain api
$domain = $client->domain();

// return a collection of Domain entity
$domains = $domain->getAll();

// return the Domain entity 'foo.dk'
$domainFooDk = $domain->getByName('foo.dk');

// return the created Domain named 'bar.dk' and pointed to ip '127.0.0.1'
$created = $domain->create('bar.dk', '127.0.0.1');

// remove the domain named 'baz.dk'
$domain->remove('baz.dk');

Domain Record

…

Droplet

…

Firewall

…

Image

…

Key

…

Load Balancer

…

Monitoring

…

Project Resources

…

Region

php
// return the region api
$region = $client->region();

// return a collection of Region entity
$regions = $region->getAll();

Size

php
// return the size api
$size = $client->size();

// return a collection of Size entity
$sizes = $size->getAll();

Tag

php
// return the tag api
$tag = $client->tag();

// return a collection of Tag entity
$tags = $tag->getAll();

// return a Tag entity by name
$tagEntity = $tag->getByName('awesome');

// create a tag
$createdTag = $tag->create('awesome');

// tag resources
$tag->tagResources('awesome', [["resource_id" => "9569411", "resource_type" => "droplet"]]);

// untag resources
$tag->untagResources('awesome', [["resource_id" => "9569411", "resource_type" => "droplet"]]);

// remove tag
$tag->remove('awesome');

Volume

…

VPC

php
// return the VPC api
$vpc = $client->vpc();

// returns all VPCs
$vpcs = $vpc->getAll();

Contributing

We will gladly receive issue reports and review and accept pull requests, in accordance with our code of conduct and contribution guidelines!

$ make install
$ make test

Security

If you discover a security vulnerability within this package, please send an email to [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

License

DigitalOcean PHP API Client is licensed under The MIT License (MIT).

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPapiapi-clientdigitaloceandigitalocean-api

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具