A Laravel package for managing Gandi domains and DNS records through the Gandi API.
Install the package via Composer:
composer require metaverse-systems/gandi-clientAdd your Gandi Personal Access Token to your .env file:
GANDI_PERSONAL_ACCESS_TOKEN=your_gandi_personal_access_token_here
GANDI_BASE_URL=https://api.gandi.netYou can create a Personal Access Token in your Gandi Admin dashboard.
You can publish the configuration file to customize the package settings:
php artisan vendor:publish --tag=gandi-configThis will create a config/gandi.php file where you can customize the package settings.
use MetaverseSystems\GandiClient\Facades\Gandi;
// Get all domains
$domains = Gandi::getDomains();
// Get specific domain information
$domain = Gandi::getDomain('example.com');
// Get DNS records for a domain
$records = Gandi::getDnsRecords('example.com');
// Create a new DNS record
$record = Gandi::createDnsRecord('example.com', [
'rrset_name' => 'www',
'rrset_type' => 'A',
'rrset_values' => ['192.168.1.1'],
'rrset_ttl' => 3600
]);
// Update a DNS record
$updatedRecord = Gandi::updateDnsRecord('example.com', 'record-id', [
'rrset_values' => ['192.168.1.2']
]);
// Delete a DNS record
Gandi::deleteDnsRecord('example.com', 'record-id');use MetaverseSystems\GandiClient\GandiClient;
class DomainController extends Controller
{
public function __construct(private GandiClient $gandiClient)
{
}
public function index()
{
$domains = $this->gandiClient->getDomains();
return view('domains.index', compact('domains'));
}
}getDomains()- Get all domainsgetDomain(string $domain)- Get specific domain information
getDnsRecords(string $domain)- Get all DNS records for a domaincreateDnsRecord(string $domain, array $record)- Create a new DNS recordupdateDnsRecord(string $domain, string $recordId, array $record)- Update a DNS recorddeleteDnsRecord(string $domain, string $recordId)- Delete a DNS record
The following configuration options are available in config/gandi.php:
personal_access_token- Your Gandi Personal Access Tokenbase_url- The Gandi API base URL (default: https://api.gandi.net)timeout- Request timeout in seconds (default: 30)verify_ssl- Whether to verify SSL certificates (default: true)
This package is open-sourced software licensed under the MIT license.