Installation
Run composer require dekalee/enom-bundle to add the package to your Laravel project.
Register the service provider in config/app.php under providers:
Dekalee\EnomBundle\EnomServiceProvider::class,
Publish the config file (if needed) with:
php artisan vendor:publish --provider="Dekalee\EnomBundle\EnomServiceProvider" --tag="config"
Configuration
Add your Enom API credentials to .env:
ENOM_USERNAME=your_username
ENOM_PASSWORD=your_password
ENOM_SANDBOX=false
The bundle expects these keys by default (verify via config/enom.php after publishing).
First Use Case
Inject the EnomClient into a service or controller:
use Dekalee\EnomBundle\Client\EnomClient;
public function __construct(EnomClient $enomClient) {
$this->enomClient = $enomClient;
}
Test a basic domain lookup:
$domainInfo = $this->enomClient->getDomainInfo('example.com');
Domain Management
createDomain() with required parameters (e.g., period, nameservers).
$this->enomClient->createDomain([
'domain' => 'example.com',
'period' => 1, // Years
'nameservers' => ['ns1.example.com', 'ns2.example.com'],
]);
renewDomain() with the domain name and period.
$this->enomClient->renewDomain('example.com', 2); // Renew for 2 years
transferDomain() and acceptTransfer().
$this->enomClient->transferDomain('example.com', 'authCode123');
DNS Management
Leverage the getDnsRecords() and updateDnsRecords() methods for dynamic DNS updates:
$records = $this->enomClient->getDnsRecords('example.com');
$this->enomClient->updateDnsRecords('example.com', [
['type' => 'A', 'name' => 'www', 'address' => '192.0.2.1'],
]);
Event-Driven Integrations
Use the EnomEvents facade to listen for domain lifecycle events (e.g., DomainRenewalFailed):
use Dekalee\EnomBundle\Events\EnomEvents;
EnomEvents::listen('DomainRenewalFailed', function ($event) {
Log::error("Renewal failed for {$event->domain}", $event->data);
});
Bulk Operations
For large-scale actions (e.g., renewing 100+ domains), batch requests using batchDomains():
$domains = ['example1.com', 'example2.com'];
$this->enomClient->batchDomains($domains, 'renew', ['period' => 1]);
dispatch(new RenewDomainsJob(['example1.com', 'example2.com'], 1));
$domainInfo = Cache::remember("enom:domain:example.com", 300, function () {
return $this->enomClient->getDomainInfo('example.com');
});
try {
$this->enomClient->renewDomain('example.com', 1);
} catch (EnomException $e) {
if ($e->getCode() === 429) {
sleep(10);
retry();
}
throw $e;
}
Authentication Failures
ENOM_USERNAME/ENOM_PASSWORD are missing or incorrect.Route::get('/enom/health', function (EnomClient $client) {
try {
$client->getAccountInfo();
return response()->json(['status' => 'healthy']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
});
Sandbox Mode Quirks
ENOM_SANDBOX=true) may return mock data that doesn’t match production behavior.Rate Limiting
$attempts = 0;
while ($attempts < 3) {
try {
$this->enomClient->batchDomains(...);
break;
} catch (RateLimitException $e) {
$attempts++;
sleep(2 ** $attempts);
}
}
Deprecated Methods
dekalee/enom library may change method signatures without major version bumps.dekalee/enom package to a specific version in composer.json:
"require": {
"dekalee/enom": "1.0.0"
}
ENOM_DEBUG=true in .env to log raw API responses.Dekalee\EnomBundle\Exception\EnomException for detailed error messages:
catch (EnomException $e) {
Log::error('Enom Error: ' . $e->getMessage(), [
'code' => $e->getCode(),
'response' => $e->getResponse(),
]);
}
Custom Responses Transform API responses using a decorator pattern:
$client->setResponseTransformer(function ($response) {
return collect($response)->map(function ($item) {
$item['formatted_price'] = '$' . $item['price'];
return $item;
});
});
Webhook Handlers
Extend the EnomWebhookHandler to process Enom’s push notifications:
class CustomWebhookHandler extends EnomWebhookHandler {
protected function handleDomainRenewal($data) {
// Custom logic (e.g., update CRM)
}
}
Register it in EnomServiceProvider:
$this->app->bind(EnomWebhookHandler::class, CustomWebhookHandler::class);
Mocking for Tests
Use Laravel’s Mockery to stub the EnomClient in unit tests:
$mock = Mockery::mock(EnomClient::class);
$mock->shouldReceive('getDomainInfo')
->with('example.com')
->andReturn(['status' => 'active']);
$this->app->instance(EnomClient::class, $mock);
How can I help you explore Laravel packages today?