dekalee/enom
Laravel package for integrating with the eNom domain registrar API. Provides an easy way to manage domains and related registrar operations from your Laravel app, including configuration helpers and API client utilities.
Installation
composer require dekalee/enom
Publish the config file (if available):
php artisan vendor:publish --provider="Dekalee\Enom\EnomServiceProvider"
Configuration
.env:
ENOM_API_KEY=your_api_key_here
ENOM_API_SECRET=your_api_secret_here
ENOM_API_SANDBOX=false # Set to true for testing
config/enom.php) matches your needs.First Use Case: Domain Registration
use Dekalee\Enom\Enom;
$enom = app(Enom::class);
$domain = $enom->domains()->register('example.com', [
'period' => 1, // 1-year registration
'nameservers' => ['ns1.example.com', 'ns2.example.com'],
]);
Key Classes to Explore
Enom (Facade): Main entry point.Domain (Resource): Represents domain objects.Transfer (Resource): Handles domain transfers.Contact (Resource): Manages registrant/contacts.$available = $enom->domains()->check('example.com');
$domain = $enom->domains()->renew('example.com', 2); // Renew for 2 years
$domain = $enom->domains()->updateNameservers('example.com', [
'ns1.example.com', 'ns2.example.com'
]);
$contact = $enom->contacts()->create([
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john@example.com',
'phone' => '+1234567890',
]);
$domain = $enom->domains()->updateContact('example.com', 'registrant', $contact->id);
$transfer = $enom->transfers()->initiate('example.com', [
'auth_code' => 'ABC123', // EPP code
'period' => 1,
]);
$transfer = $enom->transfers()->accept($transfer->id);
$domains = collect(['example.com', 'test.com']);
$domains->each(fn($domain) => $enom->domains()->check($domain));
Service Providers
Bind the Enom facade in AppServiceProvider for cleaner usage:
public function register()
{
$this->app->bind('enom', fn($app) => new Enom($app['config']['enom']));
}
Event Handling Listen for domain events (if supported) to trigger workflows:
Event::listen(DomainRegistered::class, function ($domain) {
// Send welcome email, log activity, etc.
});
API Rate Limiting Implement a queue for bulk operations to avoid hitting rate limits:
foreach ($domains as $domain) {
Queue::push(new RegisterDomainJob($domain));
}
Testing Use the sandbox environment for tests:
$this->app->singleton(Enom::class, fn() => new Enom([
'sandbox' => true,
'api_key' => 'test_key',
'api_secret' => 'test_secret',
]));
API Key Permissions
Domain:Register, Contact:Create).Sandbox vs. Production
example.com) may not be available for registration.sandbox123.com for testing.Auth Codes for Transfers
Rate Limits
try {
$domain = $enom->domains()->register('example.com', [...]);
} catch (RateLimitExceededException $e) {
sleep(10); // Wait and retry
retry();
}
Timeouts
max_execution_time or use queues.Enable Debug Mode
Set ENOM_DEBUG=true in .env to log raw API responses:
ENOM_DEBUG=true
Check logs in storage/logs/laravel.log.
Common Errors
InvalidDomain: Domain not available or invalid format.
Fix: Validate domain format (e.g., Str::lower($domain)->contains('.')).AuthenticationFailed: Incorrect API key/secret.
Fix: Regenerate keys in Enom’s API settings.InsufficientFunds: Account balance too low.
Fix: Check balance via $enom->account()->balance().Webhook Verification
If using webhooks, verify the X-Enom-Signature header matches:
$signature = hash_hmac('sha256', $payload, config('enom.webhook_secret'));
if (!hash_equals($request->header('X-Enom-Signature'), $signature)) {
abort(403);
}
Custom Resources
Extend the base Resource class to add domain-specific logic:
class CustomDomain extends \Dekalee\Enom\Resources\Domain
{
public function addSsl()
{
return $this->callApi('POST', "/domains/{$this->id}/ssl");
}
}
Middleware for API Calls Add middleware to log or transform requests/responses:
$enom->extend(function ($enom) {
$enom->getMiddleware()->push(function ($request) {
// Log request
Log::debug('Enom API Call', ['url' => $request->url(), 'data' => $request->data()]);
});
});
Webhook Handlers Create a dedicated handler for Enom webhooks:
class EnomWebhookHandler
{
public function handle($event, $payload)
{
match ($event) {
'domain.registered' => $this->handleDomainRegistered($payload),
default => Log::warning("Unhandled Enom event: {$event}"),
};
}
}
Fallback for Missing Features Use Laravel’s HTTP client as a fallback for unsupported endpoints:
$response = Http::withHeaders([
'Authorization' => 'Basic ' . base64_encode(config('enom.api_key').':'.config('enom.api_secret')),
])->post('https://api.enom.com/xml/api', $xmlPayload);
How can I help you explore Laravel packages today?