1. Go to this page and download the library: Download edsi-tech/gandi-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$domain = "example.com";
$domainAPI = $this->get('edsitech_gandi.domain_availibility');
$domain = idn_to_ascii($domain); //needed for special chars domains
$result = $domainAPI->isAvailable([$domain]); //this is an array, you can pass multiple domains
print_r($result); //the result is also an array, the key is the domain name and the value is the result.
use EdsiTech\GandiBundle\Model\Domain;
use EdsiTech\GandiBundle\Model\Contact;
use EdsiTech\GandiBundle\Model\Operation;
use EdsiTech\GandiBundle\Exception\APIException;
$fqdn = "example.com";
$myHandle = "XYZ-GANDI";
$domain = new Domain($fqdn);
$domain->setDuration(1) //years
->setAutorenew(true)
->setOwnerContact(new Contact($myHandle))
;
//others contact informations are taken from the default_handles config keys.
$domainRepository = $this->get('edsitech_gandi.domain_repository');
try {
$result = $domainRepository->register($domain);
if($result instanceof Operation) {
echo "Operation in progress";
}
} catch (APIException $e) {
$message = $e->getMessage();
echo "Error: ".$message;
}