2017 © Pedro PelĂĄez
 

library php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

image

africc/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  • Thursday, June 29, 2017
  • by lifeofguenter
  • Repository
  • 9 Watchers
  • 25 Stars
  • 3,567 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 19 Forks
  • 7 Open issues
  • 14 Versions
  • 9 % Grown

The README.md

build and publish Scrutinizer Code Quality Coverage Status Latest Stable Version Packagist Latest Unstable Version License, (*1)

php-epp2

php-epp2 is a High Level Extensible Provisioning Protocol (EPP) TCP/SSL client written in modern PHP., (*2)

Released under the GPLv3 License, feel free to contribute (fork, create meaningful branchname, issue pull request with thus branchname)!, (*3)

Table of Contents generated with DocToc, (*4)

Requirements

  • PHP 5.5+
  • php-ext-intl
  • php-ext-openssl

Features

  • modern PHP standards
    • PSR-1, PSR-2 & PSR-4
    • notice and warning free (find them, and I'll fix it!)
  • high-level usage (Plug & Play)
  • simplified client for socket and http(s) connections (auto login/logout, auto inject clTRID)
  • SSL (+local-cert)
  • XPath like setter to simplify the creation of complex XML structures
  • XML based responses for direct traversal via XPath
  • RFC 5730, RFC 5731, RFC 5732, RFC 5733, RFC 5734 & RFC 3915
  • DNSSEC support RFC 5910

Install

Via Composer, (*5)

$ composer require africc/php-epp2

Usage

See the examples folder for a more or less complete usage reference. Additionally have a look at whmcs-registrars-coza which is a WHMCS Registrar Module for the co.za zone using this library., (*6)

Basic Client Connection

this will automatically login on connect() and logout on close(), (*7)

<?php
require 'vendor/autoload.php';

use AfriCC\EPP\Client as EPPClient;

$epp_client = new EPPClient([
    'host' => 'epptest.org',
    'username' => 'foo',
    'password' => 'bar',
    'services' => [
        'urn:ietf:params:xml:ns:domain-1.0',
        'urn:ietf:params:xml:ns:contact-1.0'
    ],
    'debug' => true,
]);

try {
    $greeting = $epp_client->connect();
} catch(Exception $e) {
    echo $e->getMessage() . PHP_EOL;
    unset($epp_client);
    exit(1);
}

$epp_client->close();

Create Frame Objects

setXXX() indicates that value can only be set once, re-calling the method will overwrite the previous value., (*8)

addXXX() indicates that multiple values can exist, re-calling the method will add values., (*9)

<?php
require 'vendor/autoload.php';

use AfriCC\EPP\Frame\Command\Create\Host as CreateHost;

$frame = new CreateHost();
$frame->setHost('ns1.example.com');
$frame->setHost('ns2.example.com');
$frame->addAddr('8.8.8.8');
$frame->addAddr('8.8.4.4');
$frame->addAddr('2a00:1450:4009:809::1001');
echo $frame;

// or send frame to previously established connection
$epp_client->sendFrame($frame);

Parse Response

You can either access nodes directly by passing through a xpath or use the data() Method which will return an assoc array., (*10)

use AfriCC\EPP\Frame\Command\Check\Domain as DomainCheck;
use AfriCC\EPP\Frame\Response;

$frame = new DomainCheck();
$frame->addDomain('example.org');
$frame->addDomain('example.net');
$frame->addDomain('example.com');

$response = $epp_client->request($frame);
if (!($response instanceof Response)) {
    echo 'response error' . PHP_EOL;
    unset($epp_client);
    exit(1);
}

$result = $response->results()[0];

echo $result->code() . PHP_EOL;
echo $result->message() . PHP_EOL;
echo $response->clientTransactionId() . PHP_EOL;
echo $response->serverTransactionId() . PHP_EOL;
$data = $response->data();
if (empty($data) || !is_array($data)) {
    echo 'empty response data' . PHP_EOL;
    unset($epp_client);
    exit(1);
}

foreach ($data['chkData']['cd'] as $cd) {
    printf('Domain: %s, available: %d' . PHP_EOL, $cd['name'], $cd['@name']['avail']);
}

Custom ObjectSpec

If registrar you're working with uses custom namespace names (eg NASK) you can use custom ObjectSpec. Clients always use specified ObjectSpec when decoding responses from EPP server., (*11)

You can use this feature as follows:, (*12)

use AfriCC\EPP\HTTPClient as EPPClient;
use \AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Frame\Command\Poll;

$objectSpec = new NASKObjectSpec();
$config = [
    'host' => 'https://app.registrar.tld',
    'username' => 'user',
    'password' => 'pass',
    'services' => $objectSpec->services,
    'serviceExtensions' => $objectSpec->serviceExtensions,
];

$epp_client = new EPPClient($config, $objectSpec);

$frame = new Poll($epp_client->getObjectSpec());

or you can create frames with custom ObjectSpec:, (*13)

use AfriCC\EPP\Extension\NASK\Update\Future as UpdateFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

$frame = new UpdateFuture(new NASKObjectSpec());
$frame->setFuture('example7.pl');
$frame->changeRegistrant('mak21');
$frame->changeAuthInfo('2fooBAR');
echo $frame;

You can also create different clients with different ObjectSpec and then you can use getObjectSpec method when creating any request frame:, (*14)

use AfriCC\EPP\ObjectSpec as DefaultObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Client as EPPClient;
use AfriCC\EPP\HTTPClient as HTTPEPPClient;
use AfriCC\EPP\Frame\Command\Poll;

//...
$nask_objectspec = new NASKObjectSpec();
$default_objectspec = new DefaultObjectSpec();

$nask_client = new HTTPEPPClient($nask_config, $nask_objectspec);
$http_client = new HTTPEPPClient($http_config, $default_objectspec);
$socket_client = new EPPClient($socket_config, $default_objectspec);
$nask_socket_client = new EPPClient($nask_socket_config, $nask_objectspec);

$nask_poll = new Poll($nask_client->getObjectSpec());
$default_poll = new Poll($socket_client->getObjectSpec());

You can also change Client's objectSpec on the fly via setObjectSpec method:, (*15)

use AfriCC\EPP\ObjectSpec as DefaultObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Client as EPPClient;

//...
$nask_objectspec = new NASKObjectSpec();
$default_objectspec = new DefaultObjectSpec();

$variable_client = new EPPClient($socket_config, $default_objectspec);

//calls to getObjectSpec will return default objectSpec and responses
//will be parsed using default ObjectSpec

$variable_client->setObjectSpec($nask_objectspec);

//calls to getObjectSpec will return NASK objectSpec and responses
//will be parsed using NASK ObjectSpec

Future

  • stricter response parsing
  • stricter request validation
  • make it server capable (in conjunction with apache mod_epp)

Credits

Acknowledgments

License

php-epp2 is released under the GPLv3 License. See the bundled LICENSE file for details., (*16)

The Versions

29/06 2017

dev-master

9999999-dev https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • ext-intl *
  • php >=5.5.0
  • ext-openssl *

 

The Development Requires

client domains tcp registry registrar epp

27/04 2017

0.3.1

0.3.1.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5.0
  • ext-intl *
  • ext-openssl *

 

The Development Requires

client domains tcp registry registrar epp

02/04 2017

0.3.0

0.3.0.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5.0
  • ext-intl *
  • ext-openssl *

 

client domains tcp registry registrar epp

01/04 2017

0.2.0

0.2.0.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5.0
  • ext-intl *
  • ext-openssl *

 

client domains tcp registry registrar epp

01/04 2017

dev-analysis-8m935Y

dev-analysis-8m935Y https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5.0
  • ext-intl *
  • ext-openssl *

 

client domains tcp registry registrar epp

17/07 2016

0.1.7

0.1.7.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

25/05 2016

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

30/11 2015

0.1.6

0.1.6.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

02/05 2015

0.1.5

0.1.5.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

22/04 2015

0.1.4

0.1.4.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

19/06 2014

0.1.3

0.1.3.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

18/06 2014

0.1.2

0.1.2.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

13/06 2014

0.1.1

0.1.1.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp

11/06 2014

0.1.0

0.1.0.0 https://github.com/AfriCC/php-epp2

A High Level EPP (Extensible Provisioning Protocol) TCP/SSL Client for PHP

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.4.0
  • ext-intl *
  • ext-mcrypt *

 

client domains tcp registry registrar epp