pxgamer/digitalocean-php
Composer 安装命令:
composer require pxgamer/digitalocean-php
包简介
An easy to use wrapper for the DigitalOcean API written in PHP.
README 文档
README
An easy to use wrapper for the DigitalOcean API written in PHP.
Structure
src/
tests/
vendor/
Install
Via Composer
$ composer require pxgamer/digitalocean-php
Usage
use \pxgamer\DigitalOcean\Client; $client = new Client();
Classes
Client
- This is the main class and is used to hold the CURL functions. It also contains the API key, and should be called first.
- This class must be passed to other classes upon their initialisation.
Account
- This class is used to retrieve account information.
Domains
- This class is used to modify and retrieve domain information.
Droplets
- This class is used to manage multiple droplets, or all droplets for an account.
Droplet
- This class is used to manage droplets individually and can provides functions such as creating snapshots, enabling and disabling features, etc.
// Use the specific classes as their short names use \pxgamer\DigitalOcean; // Create a new Client instance $client = new DigitalOcean\Client(); $client->setAuthKey('API_KEY'); // Initialise a new instance of each class $account = new DigitalOcean\Account($client); $domains = new DigitalOcean\Domains($client); $droplets = new DigitalOcean\Droplets($client); $droplet = new DigitalOcean\Droplet($client);
Methods
Client Class
/** * This is required to be initialised first. * It must be passed into all other classes. */ use \pxgamer\DigitalOcean\Client; $client = new Client(); $client->setAuthKey('API_KEY');
Account Class
Initialise Account Class
use \pxgamer\DigitalOcean\Account; $account = new Account($client);
Getting Account Information
$account->getAccount();
Domains Class
Initialise Domains Class
use \pxgamer\DigitalOcean\Domains; $domains = new Domains($client);
Getting a list of domains
$domains->listDomains();
Getting information for a specific domain
$domains->getDomain('example.com');
Create a new domain
$domains->createDomain('example.com');
Deleting a domain
$domains->deleteDomain('example.com');
Droplets Class
Initialise Droplets Class
// Requires the Client class to be initialised use \pxgamer\DigitalOcean\Droplets; $droplets = new Droplets($client);
Listing droplets
$droplets->listDroplets();
Listing neighbours of Droplets (droplets in the same location)
$droplets->listNeighbours();
Droplet Class
Initialise Droplet Class
// Requires the Client class to be initialised use \pxgamer\DigitalOcean\Droplet; $droplet = new Droplet($client);
Setting the Droplet ID
$droplet->setDroplet('DROPLET_ID');
Getting information about a droplet
// Requires the droplet ID to be set $droplet->getDroplet();
Creating a Droplet
$dropletAttributes = (array)[ 'name' => 'example.com', // Required 'region' => 'nyc3', // Required 'size' => '512mb', // Required 'image' => 'ubuntu-14-04-x64', // Required 'ssh_keys' => null, 'backups' => false, 'ipv6' => true, 'user_data' => null, 'private_networking' => null, 'volume' => null, 'tags' => [ 'web' ], ]; $droplet->createDroplet($dropletAttributes);
Deleting a Droplet
// Requires the droplet ID to be set $droplet->deleteDroplet();
Listing a Droplet's neighbours
// Requires the droplet ID to be set $droplet->listNeighbours();
Create a snapshot
// Requires the droplet ID to be set $droplet->createSnapshot('SNAPSHOT-NAME');
Enabling backups for a Droplet
// Requires the droplet ID to be set $droplet->enableBackups();
Disabling backups for a Droplet
// Requires the droplet ID to be set $droplet->disableBackups();
Rebooting a Droplet
// Requires the droplet ID to be set $droplet->reboot();
Power Cycling a Droplet
// Requires the droplet ID to be set $droplet->powerCycle();
Shutting down a Droplet
// Requires the droplet ID to be set $droplet->shutdown();
Powering off a Droplet
// Requires the droplet ID to be set $droplet->powerOff();
Powering on a Droplet
// Requires the droplet ID to be set $droplet->powerOn();
Resizing a Droplet
/** * Requires the droplet ID to be set * * Attributes: * - $size [string] (e.g. '1gb') * - $increaseDiskSize [boolean] (e.g. false) - Determines whether this is a permanent resize or not */ $droplet->resize('1gb', false);
Reset a Droplet's password
// Requires the droplet ID to be set $droplet->passwordReset();
Renaming a Droplet
// Requires the droplet ID to be set $droplet->rename('NEW_DROPLET_NAME');
Enable IPv6 for a Droplet
// Requires the droplet ID to be set $droplet->enableIPv6();
Enable Private Networking for a Droplet
// Requires the droplet ID to be set $droplet->enablePrivateNetworking();
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email owzie123@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
pxgamer/digitalocean-php 适用场景与选型建议
pxgamer/digitalocean-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 79 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pxgamer/digitalocean-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pxgamer/digitalocean-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 79
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-07