community-sdks/domain-providers-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

community-sdks/domain-providers-php

Composer 安装命令:

composer require community-sdks/domain-providers-php

包简介

Capability-based domain provider contract implementation for PHP with GoDaddy adapter.

README 文档

README

PHP implementation of the contracts specification.

This package provides:

  • contract-aligned DTOs and operation interfaces
  • capability-aware provider abstraction
  • provider adapters for Spaceship and GoDaddy

Install

composer require community-sdks/domain-providers-php

Spaceship and GoDaddy support are included out of the box.

Quick start (Spaceship)

<?php

declare(strict_types=1);

use DomainProviders\DTO\DnsRecord;
use DomainProviders\DTO\DomainContact;
use DomainProviders\DTO\DomainName;
use DomainProviders\DTO\DomainRegistrationPeriod;
use DomainProviders\DTO\NameserverSet;
use DomainProviders\Provider\Spaceship\SpaceshipConfig;
use DomainProviders\Provider\Spaceship\SpaceshipProviderFactory;

$config = new SpaceshipConfig(
    apiKey: 'your-key',
    apiSecret: 'your-secret',
    environment: 'sandbox', // or 'production'
    onlyTlds: ['com', 'net'],
    exceptTlds: ['io'],
    priority: 10,
);

$provider = SpaceshipProviderFactory::fromConfig($config);

$availability = $provider->checkAvailability(new DomainName('example.com'));

if ($availability->available) {
    $registrant = new DomainContact(
        fullName: 'Jane Doe',
        email: 'jane@example.com',
        phone: '+12025550123',
        addressLine1: '123 Main Street',
        addressLine2: null,
        city: 'Phoenix',
        stateOrRegion: 'AZ',
        postalCode: '85001',
        countryCode: 'US',
        organization: null,
    );

    $provider->registerDomain(
        domain: new DomainName('example.com'),
        period: new DomainRegistrationPeriod(1),
        registrantContact: $registrant,
        nameservers: new NameserverSet(['ns1.example.com', 'ns2.example.com']),
        privacyEnabled: true,
    );
}

$records = $provider->listDnsRecords(new DomainName('example.com'));

$provider->createDnsRecord(
    new DomainName('example.com'),
    new DnsRecord(
        id: null,
        type: 'A',
        name: '@',
        value: '203.0.113.10',
        ttl: 3600,
    ),
);

Quick start (GoDaddy)

<?php

declare(strict_types=1);

use DomainProviders\DTO\DomainName;
use DomainProviders\DTO\DomainRegistrationPeriod;
use DomainProviders\DTO\ProviderRequestContext;
use DomainProviders\Provider\GoDaddy\GoDaddyConfig;
use DomainProviders\Provider\GoDaddy\GoDaddyProviderFactory;

$config = new GoDaddyConfig(
    apiKey: 'your-key',
    apiSecret: 'your-secret',
    // Use reseller mode with customerId for /v2/customers/* endpoints,
    // or direct mode without customerId for /v1/domains/* endpoints.
    accountMode: GoDaddyConfig::ACCOUNT_MODE_DIRECT,
    customerId: null,
    // Routing fields shared by all ProviderConfig implementations:
    onlyTlds: null,
    exceptTlds: ['rs', 'co.rs', 'in.rs'],
    priority: 20,
    priorityTlds: ['net'],
);

$provider = GoDaddyProviderFactory::fromConfig($config);

$availability = $provider->checkAvailability(new DomainName('example.com'));

if ($availability->available) {
    $result = $provider->renewDomain(
        new DomainName('example.com'),
        new DomainRegistrationPeriod(1)
    );
}

// Request-scoped values like shopper and market are passed where needed:
$domains = $provider->listDomains(status: 'active', shopperId: 'optional-shopper-id');

// Or pass provider-agnostic context scopes (recommended for multi-provider use cases):
$context = new ProviderRequestContext(scopes: ['shopper_id' => 'optional-shopper-id']);
$domainsFromContext = $provider->listDomains(status: 'active', context: $context);

Provider-agnostic routing handler

Use DomainProviderHandler to register multiple providers and route by TLD rules.

<?php

declare(strict_types=1);

use DomainProviders\DTO\DomainName;
use DomainProviders\Handler\DomainProviderHandler;
use DomainProviders\Provider\GoDaddy\GoDaddyConfig;
use DomainProviders\Provider\GoDaddy\GoDaddyProviderFactory;
use DomainProviders\Provider\Spaceship\SpaceshipConfig;
use DomainProviders\Provider\Spaceship\SpaceshipProviderFactory;

$spaceshipConfig = new SpaceshipConfig(
    apiKey: 'sp-key',
    apiSecret: 'sp-secret',
    environment: 'sandbox',
    onlyTlds: ['rs', 'co.rs', 'in.rs'],
    priority: 10,
    priorityTlds: ['com'],
);

$godaddyConfig = new GoDaddyConfig(
    apiKey: 'gd-key',
    apiSecret: 'gd-secret',
    customerId: 'gd-customer',
    accountMode: GoDaddyConfig::ACCOUNT_MODE_RESELLER,
    exceptTlds: ['rs', 'co.rs', 'in.rs'],
    priority: 20,
);

$handler = (new DomainProviderHandler())
    ->registerProvider('spaceship', SpaceshipProviderFactory::fromConfig($spaceshipConfig), $spaceshipConfig)
    ->registerProvider('godaddy', GoDaddyProviderFactory::fromConfig($godaddyConfig), $godaddyConfig)
    ->preferProviderForTld('com', 'spaceship');

$availability = $handler->checkAvailability(new DomainName('example.co.rs')); // routed to spaceship
$comAvailability = $handler->checkAvailability(new DomainName('example.com')); // prefers spaceship

// If provider supports TLD discovery, you can inspect its live TLD list.
$spaceshipTlds = $handler->listProviderTlds('spaceship');

Routing decision order for domain-based operations:

  • explicit preferProviderForTld() match
  • onlyTlds and exceptTlds filtering
  • priorityTlds match
  • numeric priority (lower number = higher priority)

Contract coverage

This package includes contract methods for:

  • check availability
  • register domain
  • renew domain
  • transfer domain
  • get domain info
  • list domains
  • get/set nameservers
  • list/create/update/delete DNS records
  • get pricing
  • check transfer availability
  • provider metadata and capabilities

Unsupported provider operations are reported through UnsupportedCapabilityException.

Method docs

Detailed method-by-method documentation is available in:

Custom providers outside this package

You can register custom providers (class, instance, or factory) using ProviderRegistry.

<?php

use DomainProviders\Registry\ProviderRegistry;
use Vendor\Custom\MyProvider;

$registry = new ProviderRegistry();

$registry->registerClass('my-provider', MyProvider::class);
// or registerInstance('my-provider', new MyProvider())
// or registerFactory('my-provider', fn() => new MyProvider($deps))

$provider = $registry->get('my-provider');

Provider notes (GoDaddy)

  • Supports both GoDaddy reseller account endpoints (/v2/customers/*) and direct account endpoints (/v1/domains/*) via GoDaddyConfig::accountMode.
  • In reseller mode, customerId is required. In direct mode, customerId can be null.
  • The community-sdks/godaddy-php client currently exposes DNS retrieval by {type}/{name} path, not a full zone list endpoint in this adapter.
  • Because of that, dns_record_list is declared unsupported for now, while create/update/delete DNS operations are supported.

Provider notes (Spaceship)

  • Uses SpaceshipConfig::environment with sandbox or production to select the API base environment.
  • Supports domain availability, registration, renewal, transfer, domain info, nameserver read/update, and DNS record list/create/update/delete.
  • pricing_lookup is currently declared unsupported in this adapter.

community-sdks/domain-providers-php 适用场景与选型建议

community-sdks/domain-providers-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 community-sdks/domain-providers-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-09