PHP code example of utopia-php / domains
1. Go to this page and download the library: Download utopia-php/domains 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/ */
utopia-php / domains example snippets
topia\Domains\Domain;
// demo.example.co.uk
$domain = new Domain('demo.example.co.uk');
$domain->get(); // demo.example.co.uk
$domain->getTLD(); // uk
$domain->getSuffix(); // co.uk
$domain->getRegisterable(); // example.co.uk
$domain->getName(); // example
$domain->getSub(); // demo
$domain->isKnown(); // true
$domain->isICANN(); // true
$domain->isPrivate(); // false
$domain->isTest(); // false
// demo.localhost
$domain = new Domain('demo.localhost');
$domain->get(); // demo.localhost
$domain->getTLD(); // localhost
$domain->getSuffix(); // ''
$domain->getRegisterable(); // ''
$domain->getName(); // demo
$domain->getSub(); // ''
$domain->isKnown(); // false
$domain->isICANN(); // false
$domain->isPrivate(); // false
$domain->isTest(); // true
use Utopia\Domains\Registrar;
use Utopia\Domains\Contact;
use Utopia\Domains\Registrar\OpenSRS;
$opensrs = new OpenSRS(
'apikey',
'apisecret',
'username',
'password',
[
'ns1.nameserver.com',
'ns2.nameserver.com',
]
);
$reg = new Registrar($opensrs);
$contact = new Contact(
'firstname',
'lastname',
'phone',
'email',
'address1',
'address2',
'address3',
'city',
'state',
'country',
'postalcode',
'org',
'owner',
);
$domain = 'yourname.com';
$available = $reg->available($domain);
$purchase = $reg->purchase($domain, $contact);
$suggest = $reg->suggest(['yourname', 'yourname1.com'], ['com', 'net', 'org']);
$domainDetails = $reg->getDomain($domain);
$renew = $reg->renew($domain, 1);
$transfer = $reg->transfer($domain, [$contact]);
bash
composer
bash
php ./data/import.php