sysborg / check-my-domain
A lightweight Laravel package for domain ownership verification using DNS TXT records.
0.0.3
2025-07-24 02:32 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- orchestra/testbench: ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.5 || ^10.0
README
A lightweight and developer-friendly Laravel package for verifying domain ownership using DNS TXT records.
๐ Features
- ๐ Verifies domain ownership via DNS TXT records.
- โ๏ธ Easily configurable and customizable.
- ๐ Prefix-based hashing for safe and unique TXT records.
- โก Simple to integrate into any Laravel project.
๐ฆ Installation
composer require sysborg/check-my-domain
๐ ๏ธ Configuration
Optionally publish the configuration file:
php artisan vendor:publish --tag=check-my-domain-config
This will publish the file to:
config/checkMyDomain.php
Example config (config/checkMyDomain.php
)
return [ 'prefix' => 'sbv', 'settings' => [ 'use-domain' => true, ], ];
Key | Description |
---|---|
prefix |
Prefix used in the TXT record name/value (e.g., sbv=... ) |
use-domain |
If true , includes the domain name in the generated hash |
๐ง Usage
Injecting the Service
use Facades\Sysborg\CheckMyDomain\Lib\Domain; $domainService = Domain::methodName(...parameters);
Generating a TXT Record
$record = Domain::generateTxtRecord('example.com', 'user-123'); // Output: sbv=4f8a3bd9eabf3c22bb9a5e2dd5c03f4c8ae6d2ef9f709137b20a2fd4e9d1
Validating Against DNS
$isVerified = Domain::compareTxtRecord('example.com', $record); if ($isVerified) { echo 'โ Domain verified successfully!'; } else { echo 'โ Domain verification failed.'; }
๐งช Testing
composer test
Or use PHPUnit directly if configured:
./vendor/bin/phpunit
๐ Directory Structure
src/
โโโ config/
โ โโโ checkMyDomain.php
โโโ Exceptions/
โ โโโ InvalidDomainException.php
โ โโโ InvalidPrefixException.php
โโโ Lib/
โ โโโ Domain.php
โโโ Providers/
โ โโโ CheckMyDomainProvider.php
๐ How It Works
- The package generates a unique hash based on your prefix, user ID, domain, and timestamp.
- The user adds the TXT record to their DNS zone (e.g.
sbv=abcdef123456...
). - You use
compareTxtRecord()
to query the domain and validate if the correct TXT record is present.
This makes it easy to verify domain ownership for:
- User-generated domains
- SaaS onboarding
- API clients or webhook callbacks
๐งฉ Integration Ideas
- ๐ Connect to onboarding flows (verify user domains).
- ๐ก๏ธ Add protection to webhook registration or integrations.
- โ๏ธ Automate DNS verification with APIs like Cloudflare.
๐ฅ Credits
Maintained by Sysborg Created by Anderson Arruda
๐ License
MIT License. See LICENSE file for details.