A comprehensive Symfony bundle for integrating DomainNameAPI / DomainResellerAPI services with REST and SOAP support.
composer require estratos/domainname-api
// config/bundles.php
return [
// ...
Estratos\DomainNameApi\DomainNameApiBundle::class => ['all' => true],
];
# config/packages/domain_name_api.yaml
domain_name_api:
# Provider selection (rest | soap)
provider: '%env(DOMAINNAME_API_PROVIDER)%'
# REST API (recommended)
api_key: '%env(DOMAINNAME_API_KEY)%'
reseller_id: '%env(DOMAINNAME_RESELLER_ID)%'
rest:
endpoint: '%env(DOMAINNAME_API_ENDPOINT)%'
verify_ssl: true
timeout: 30
retry_attempts: 3
# SOAP API (legacy)
username: '%env(DOMAINNAME_API_USERNAME)%'
password: '%env(DOMAINNAME_API_PASSWORD)%'
test_mode: '%env(bool:DOMAINNAME_API_TEST_MODE)%'
# General
timeout: 30
default_nameservers:
- 'ns1.domainnameapi.com'
- 'ns2.domainnameapi.com'
###> estratos/domainname-api ###
# REST API (recommended)
DOMAINNAME_API_PROVIDER=rest
DOMAINNAME_API_KEY=your_api_key_here
DOMAINNAME_RESELLER_ID=your_reseller_id_here
DOMAINNAME_API_ENDPOINT=https://api.domainresellerapi.com
# SOAP API (legacy - optional)
DOMAINNAME_API_USERNAME=your_username
DOMAINNAME_API_PASSWORD=your_password
DOMAINNAME_API_TEST_MODE=false
###< estratos/domainname-api ###
# Test REST API connection
php bin/console domain:test-rest
# Check domain availability
php bin/console domain:check example.com
# Check domain with JSON output
php bin/console domain:check example.com --format=json
# Check account balance
php bin/console domain:balance
# Get balance with low balance notification
php bin/console domain:balance --notify --threshold=100
# List domains
php bin/console domain:list
# List domains with pagination
php bin/console domain:list --page=2 --limit=20
# List domains by status
php bin/console domain:list --status=active
# List available TLDs
php bin/console domain:tlds
# Search TLDs
php bin/console domain:tlds --search=.com
# Register a domain (interactive)
php bin/console domain:register example.com
# Register a domain with options
php bin/console domain:register example.com \
--period=2 \
--nameservers=ns1.example.com \
--nameservers=ns2.example.com \
--privacy \
--autorenew
Once the bundle is configured, the following endpoints are available:
GET /api/domain/{domain}/check
GET /api/domain/balance
GET /api/domain/list?page=1&limit=50
GET /api/domain/tlds
POST /api/domain/register
curl -X POST http://localhost:8000/api/domain/register \
-H "Content-Type: application/json" \
-d '{
"domain": "example.com",
"period": 1,
"registrant": {
"firstName": "John",
"lastName": "Doe",
"company": "Example Inc.",
"email": "[email protected]",
"addressLine1": "123 Main St",
"city": "New York",
"state": "NY",
"country": "US",
"zipCode": "10001",
"phone": "+1234567890"
},
"admin": {},
"technical": {},
"billing": {},
"nameservers": [
"ns1.example.com",
"ns2.example.com"
],
"privacyProtection": true
}'
use Estratos\DomainNameApi\Domain\Contract\DomainProviderInterface;
use Estratos\DomainNameApi\Domain\DTO\RegisterDomainRequest;
use Estratos\DomainNameApi\Domain\DTO\ContactDto;
class MyService
{
public function __construct(
private readonly DomainProviderInterface $domainProvider
) {
}
public function checkDomain(string $domain): void
{
$result = $this->domainProvider->check($domain);
if ($result->isAvailable()) {
echo "Domain {$result->domain} is available for {$result->getFormattedPrice()}";
}
}
public function registerDomain(string $domain): void
{
$contact = new ContactDto(
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
);
$request = new RegisterDomainRequest(
domain: $domain,
period: 1,
registrant: $contact,
admin: $contact,
technical: $contact,
billing: $contact,
nameservers: [
'ns1.example.com',
'ns2.example.com'
]
);
$result = $this->domainProvider->register($request);
if ($result->isSuccess()) {
echo "Domain registered successfully! Order ID: {$result->orderId}";
}
}
}
The bundle follows a Clean Architecture approach with Ports & Adapters.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Application Layer โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Use Cases โ โ Services โ โ Commands โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Domain Layer โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Contracts โ โ DTOs โ โ Value Objects โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Infrastructure Layer โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ REST Client โ โ SOAP Client โ โ Controllers โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Main interface for domain operations.
HTTP client abstraction for REST API communication.
Factory responsible for creating provider implementations.
# Run all tests
composer test
# Run tests with coverage
composer test-coverage
# Run PHPStan analysis
composer phpstan
# Run CS Fixer
composer cs-fix
| Parameter | Type | Default | Description |
|---|---|---|---|
| provider | string | rest | Provider to use (rest or soap) |
| api_key | string | %env(DOMAINNAME_API_KEY)% |
REST API Key |
| reseller_id | string | %env(DOMAINNAME_RESELLER_ID)% |
Reseller ID |
| rest.endpoint | string | %env(DOMAINNAME_API_ENDPOINT)% |
REST API endpoint |
| rest.verify_ssl | boolean | true | Verify SSL certificate |
| rest.timeout | integer | 30 | Request timeout in seconds |
| rest.retry_attempts | integer | 3 | Number of retry attempts |
| username | string | %env(DOMAINNAME_API_USERNAME)% |
SOAP username |
| password | string | %env(DOMAINNAME_API_PASSWORD)% |
SOAP password |
| test_mode | boolean | false | SOAP test mode |
| timeout | integer | 30 | General timeout |
| default_nameservers | array | ['ns1.domainnameapi.com', 'ns2.domainnameapi.com'] |
Default nameservers |
git checkout -b feature/amazing-feature
git commit -m "Add some amazing feature"
git push origin feature/amazing-feature
This bundle is licensed under the MIT License.
See the LICENSE file for more information.
Julio Rodriguez
GitHub: https://github.com/estratos
For support, bug reports, or feature requests, please open an issue on GitHub.
How can I help you explore Laravel packages today?