PHP code example of haphan / php-rage4dns

1. Go to this page and download the library: Download haphan/php-rage4dns 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/ */

    

haphan / php-rage4dns example snippets





 

aphan\Rage4DNS\Credentials;
use \Haphan\Rage4DNS\Rage4DNS;

// Create credential instace with your email and API client key
$credentials = new Credentials('[email protected]', '11223344556677');

// rage4 dns client instance
$rage4 = new Rage4DNS($credentials);


//...
//Get all domains
$domains = $rage4->domains->getAll();

//Retrieve domain instance using name or ID
$domain = $rage4->domains->getById(12345);
$domain = $rage4->domains->getByName('example.com');

//Create a new domain
$status = $rage4->domains->createDomain('foobar.com', '[email protected]');

//Update the domain and set vanity ns record
$status = $rage4->domains->updateDomain('12345', '[email protected]', 'example.com', 'ns', true);

//Remove a domain
$status = $rage4->domains->deleteDomain('12345');

//Export zone with BIND format
$zone = $rage4->domains->exportZone('12345');

// ...

// Get available record types
/**@var \Haphan\Rage4DNS\Entity\RecordType[] $types */
$types = $rage4->records->getTypes();

// Get available regions
/**@var \Haphan\Rage4DNS\Entity\Region[] $regions */
$regions = $rage4->records->getRegions();

// Create new Record
$record = new \Haphan\Rage4DNS\Entity\Record();
$record
    ->setName('dev.example.com')
    ->setContent('1.2.3.4')
    ->setType('2') // A record, see record types
    ->setTtl(3600)
    ->setGeoRegionId(12345) // see regions
    ->setDomainId(12345);

$status = $rage4->records->createRecord($record);


// Remove a record
$status =  $rage4->records->deleteRecord(12345);


//Update a record
/**@var \Haphan\Rage4DNS\Entity\Record $record */
$record = $rage4->records->getRecords(12345);

$record->setName('new.example.com');

$status = $rage4->records->updateRecord($record);

bash
$ curl -sS https://getcomposer.org/installer | php
bash
$ php bin/rage4dns
bash
$ php composer.phar 
json
{
    "aphan/php-rage4dns": "dev-master"
    }
}
bash
$ php composer.phar install