承接 haphan/php-rage4dns 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

haphan/php-rage4dns

Composer 安装命令:

composer require haphan/php-rage4dns

包简介

Rage4 DNS API PHP 5.3+ Library

README 文档

README

SensioLabsInsight Scrutinizer Code Quality

This PHP5.3+ library helps you to interact with the Rage4 DNS API via PHP or Console.

The Rage4 DNS is fast, reliable and cost effective authoritative name servers service designed for high availability and performance. Read more

Who use this?

  • PHP Developers who wish to integrate their products or services with Rage4 DNS
  • System admins who wish to automate tasks with Rage4DNS

Prerequisites

This library requires git, curl, php and composer.phar.

To install composer, execute following command.

$ curl -sS https://getcomposer.org/installer | php

Stand-alone console tool installation

If you are to use this as a CLI tool only (most likely for system administrators), follow these steps. Otherwise see PHP library installation.

Make sure you have composer.phar and git installed before execute following command.

$ git clone https://github.com/haphan/php-rage4dns.git rage4; cd rage4; composer.phar config bin-dir bin; composer.phar install

Modify credentials.yml to include your email and API key. Finally verify installation by execute command

$ php bin/rage4dns

PHP library installation

This library can be found on Packagist.

The recommended way to install this is through composer.

$ php composer.phar require haphan/php-rage4dns:dev-master

Or edit composer.json and add:

{
    "require": {
        "haphan/php-rage4dns": "dev-master"
    }
}

Protip: To install latest dev release, you should browse the haphan/php-rage4dns

And install dependencies:

$ php composer.phar install

Now you can add the autoloader, and you will have access to the library:

<?php

require 'vendor/autoload.php';

Compatibility

The library follows PSR-4 autoloading standard.

Compatible with all PSR-enabled frameworks and libaries, such as Symfony2, Zend Framework 2, Laravel, Phalcon.

Console commands - CLI

To use the Command line interface, you need to copy and rename the credentials.yml.dist file to credentials.yml in your project directory, then add your own Email and API key:

email: <YOUR_EMAIL>
api_key:  <YOUR_API_KEY>

If you want to use another credential file just add the option --credentials="/path/to/file" to command.

Available commands for domains

# List all registered domains
$ php bin/rage4dns domains:all
+-------+-------------+------------------------+------+-------------+
| ID    | Name        | Owner Email            | Type | Subnet Mask |
+-------+-------------+------------------------+------+-------------+
| 20000 | fooo.com    | email.1234@example.com | 0    | 0           |
| 20001 | example.net | email.1234@example.com | 0    | 0           |
| 20002 | example.com | email.1234@example.com | 0    | 0           |
+-------+-------------+------------------------+------+-------------+

# Get domain by id.
$ php bin/rage4dns domains:id 20002
+-------+-------------+------------------------+------+-------------+
| ID    | Name        | Owner Email            | Type | Subnet Mask |
+-------+-------------+------------------------+------+-------------+
| 20002 | example.com | email.1234@example.com | 0    | 0           |
+-------+-------------+------------------------+------+-------------+

# Get domain by name.
$ php bin/rage4dns domains:id example.com
+-------+-------------+------------------------+------+-------------+
| ID    | Name        | Owner Email            | Type | Subnet Mask |
+-------+-------------+------------------------+------+-------------+
| 20002 | example.com | email.1234@example.com | 0    | 0           |
+-------+-------------+------------------------+------+-------------+

# Create regular domain.
$ php bin/rage4dns domains:create foobar.com example.123@example.com
+--------+-------+-------+
| Status | ID    | Error |
+--------+-------+-------+
| true   | 27123 |       |
+--------+-------+-------+
# Create regular domain with vanity name server.
$ php bin/rage4dns domains:createVanity example2.com example.123@example.com example.com ns
+--------+-------+-------+
| Status | ID    | Error |
+--------+-------+-------+
| true   | 27997 |       |
+--------+-------+-------+

# Remove a domain
$ php bin/rage4dns domains:delete 27997
Are you sure to delete domain with id 27997 ? (y/N) y
+--------+-------+-------+
| Status | ID    | Error |
+--------+-------+-------+
| true   | 27997 |       |
+--------+-------+-------+

# Export zones as BIND compatible file format
$ php bin/rage4dns domains:export 27995
$ORIGIN foobar.com.
$TTL 1h

foobar.com.	IN	SOA	r4ns.com. example.123.example.com. (
	2014042801
	1d
	2h
	4w
	1h
	)

foobar.com.	NS	ns1.r4ns.com.
foobar.com.	NS	ns2.r4ns.com.
foobar.com.	SOA	ns1.r4ns.com example.123.example.com 2014042801 10800 3600 604800 3600

# Update a domain
$php bin/rage4dns domains:update 27995 newemail@example.com example.com ns true
+--------+-------+-------+
| Status | ID    | Error |
+--------+-------+-------+
| true   | 27995 |       |
+--------+-------+-------+

Available commands for records

# List all records for specific domain.
$ php bin/rage4dns records:all 27995
+--------+------------+------------------------------------------------------------------------+------+------+----------+--------+--------+
| ID     | Name       | Content                                                                | Type | TTL  | Priority | Region | Active |
+--------+------------+------------------------------------------------------------------------+------+------+----------+--------+--------+
| 600393 | foobar.com | ns1.example.com                                                        | NS   | 3600 |          | 0      | true   |
| 600395 | foobar.com | ns2.example.com                                                        | NS   | 3600 |          | 0      | true   |
| 600397 | foobar.com | ns1.example.com newemail.example.com 2014042803 10800 3600 604800 3600 | SOA  | 3600 |          | 0      | true   |
+--------+------------+------------------------------------------------------------------------+------+------+----------+--------+--------+

# Create a record.
$ php bin/rage4dns records:create records:create 27995 dev.foobar.com 8.8.8.8 2 3600 0
+--------+--------+-------+
| Status | ID     | Error |
+--------+--------+-------+
| true   | 600811 |       |
+--------+--------+-------+

# Delete a record
$ php bin/rage4dns records:delete 600811
Are you sure to delete record with id 600811 ? (y/N) y
+--------+--------+-------+
| Status | ID     | Error |
+--------+--------+-------+
| true   | 600811 |       |
+--------+--------+-------+

# Display all geo regions.
$ php bin/rage4dns records:regions
+------------------------+--------------+
| Name                   | Value        |
+------------------------+--------------+
| World                  | 0            |
| Africa                 | 2            |
| Americas               | 4            |
| Asia                   | 8            |
| Europe                 | 16           |
| Oceania                | 32           |
| AustraliaAndNewZealand | 64           |
| Caribbean              | 132          |
| CentralAmerica         | 260          |
| CentralAsia            | 520          |
| EasternAfrica          | 1026         |
| EasternAsia            | 2056         |
| EasternEurope          | 4112         |
| Melanesia              | 8224         |
| Micronesia             | 16416        |
| MiddleAfrica           | 32770        |
| NorthernAfrica         | 65538        |
| NorthernAmerica        | 131076       |
| NorthernEurope         | 262160       |
| Polynesia              | 524320       |
| SouthAmerica           | 1048580      |
| SouthEasternAsia       | 2097160      |
| SouthernAfrica         | 4194306      |
| SouthernAsia           | 8388616      |
| SouthernEurope         | 16777232     |
| WesternAfrica          | 33554434     |
| WesternAsia            | 67108872     |
| WesternEurope          | 134217744    |
| USRegion10             | 268566532    |
| USRegion1              | 537001988    |
| USRegion2              | 1073872900   |
| USRegion3              | 2147614724   |
| USRegion4              | 4295098372   |
| USRegion5              | 8590065668   |
| USRegion6              | 17180000260  |
| USRegion7              | 34359869444  |
| USRegion8              | 68719607812  |
| USRegion9              | 137439084548 |
| CanadaEast             | 274878038020 |
| CanadaWest             | 549755944964 |
| Closest                | -1           |
+------------------------+--------------+

# Display all available record types.
$ php bin/rage4dns records:types
+--------+-------+
| Name   | Value |
+--------+-------+
| SOA    | 0     |
| NS     | 1     |
| A      | 2     |
| AAAA   | 3     |
| CNAME  | 4     |
| MX     | 5     |
| TXT    | 6     |
| SRV    | 7     |
| PTR    | 8     |
| SPF    | 9     |
| SSHFP  | 10    |
| LOC    | 11    |
| NAPTR  | 12    |
| RRSIG  | 13    |
| DNSKEY | 14    |
| DS     | 15    |
| NSEC   | 16    |
| DNAME  | 666   |
+--------+-------+

# Update a record.
$ php bin/rage4dns records:update 600815 dev.foobar.com 8.8.8.8 2
+--------+--------+-------+
| Status | ID     | Error |
+--------+--------+-------+
| true   | 600815 |       |
+--------+--------+-------+

Available commands for usage

# Retrieve usage of a domain.
$ php bin/rage4dns usage:domain 12345
+------------+-------+
| Date       | Value |
+------------+-------+
| 2014-04-01 | 65123 |
+------------+-------+

# Retrieve global usage.
$ php bin/rage4dns usage:global
+------------+-------+
| Date       | Value |
+------------+-------+
| 2014-04-28 | 88    |
| 2014-04-27 | 268   |
| 2014-04-26 | 2936  |
| 2014-04-25 | 486   |
| 2014-04-24 | 2418  |
+------------+-------+

PHP API Usage

Construct $rage4 client instance
<?php 

require __DIR__ . '/vendor/autoload.php';

use \Haphan\Rage4DNS\Credentials;
use \Haphan\Rage4DNS\Rage4DNS;

// Create credential instace with your email and API client key
$credentials = new Credentials('email@example.com', '11223344556677');

// rage4 dns client instance
$rage4 = new Rage4DNS($credentials);
Domains related api
//...
//Get all domains
$domains = $rage4->domains->getAll();

//Retrieve domain instance using name or ID
$domain = $rage4->domains->getById(12345);
$domain = $rage4->domains->getByName('example.com');

//Create a new domain
$status = $rage4->domains->createDomain('foobar.com', 'owner@example.com');

//Update the domain and set vanity ns record
$status = $rage4->domains->updateDomain('12345', 'newOwner@example.com', 'example.com', 'ns', true);

//Remove a domain
$status = $rage4->domains->deleteDomain('12345');

//Export zone with BIND format
$zone = $rage4->domains->exportZone('12345');
Records related api
// ...

// Get available record types
/**@var \Haphan\Rage4DNS\Entity\RecordType[] $types */
$types = $rage4->records->getTypes();

// Get available regions
/**@var \Haphan\Rage4DNS\Entity\Region[] $regions */
$regions = $rage4->records->getRegions();

// Create new Record
$record = new \Haphan\Rage4DNS\Entity\Record();
$record
    ->setName('dev.example.com')
    ->setContent('1.2.3.4')
    ->setType('2') // A record, see record types
    ->setTtl(3600)
    ->setGeoRegionId(12345) // see regions
    ->setDomainId(12345);

$status = $rage4->records->createRecord($record);


// Remove a record
$status =  $rage4->records->deleteRecord(12345);


//Update a record
/**@var \Haphan\Rage4DNS\Entity\Record $record */
$record = $rage4->records->getRecords(12345);

$record->setName('new.example.com');

$status = $rage4->records->updateRecord($record);

Credits

Contributing

Please see CONTRIBUTING for details.

Acknowledgments

This project is built on top of following libraries.

Todos

  • Symfony2 coding standard compliant. Make sure source code pass phpcs
  • Example code for PHP library Add example code how to use with PHP
  • Project status badge. Add travis build status, SLInsight score, packagist download counter.
  • Tagged version release. This will come last
  • Integration with popular frameworks. Rage4DNSBundle for Symfony?

haphan/php-rage4dns 适用场景与选型建议

haphan/php-rage4dns 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「dns」 「Rage4」 「Rage4 DNS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 haphan/php-rage4dns 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 haphan/php-rage4dns 我们能提供哪些服务?
定制开发 / 二次开发

基于 haphan/php-rage4dns 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-28