PHP code example of dormilich / ripedb-client

1. Go to this page and download the library: Download dormilich/ripedb-client 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/ */

    

dormilich / ripedb-client example snippets


// create the connection object
$client = new Client(…);

// create the web service object
$ripe   = new WebService($client, [
	'environment' => WebService::PRODUCTION,
	'password'    => 'your maintainer password',
]);

// you can set also these options separately
$ripe   = new WebService($client);
$ripe->setEnvironment(WebService::PRODUCTION);

try {
	// create a RIPE object
	$me = new Person;

	// setting attributes via array style
	$me['person'] = 'John Doe';

	// setting multiple-valued attributes via array style
	$me['phone']  = [
		'+1 234 56789', 
		'+1 432 98765', 
	];

	// setting attributes via method
	$me
		->addAttribute('address', 'Any Street 1')
		->addAttribute('address', 'Anytown')
	;

	// create object in DB
	$me = $ripe->create($me);

	// display result
	echo '<pre>', $me, '</pre>';
}
catch (RPSLException $e) {
	// errors regarding the setup of the RIPE object
}
// using Guzzle 6 exceptions as example, 
// your client implementation may use different exceptions
catch (BadResponseException $e) {
	$errors = WebService::getErrors($e->getResponse()->getBody()));
}

try {
	// create a RIPE object with the object’s primary key
	$jd = new Person('JD123-RIPE');

	// fetch the object from the DB
	$jd = $ripe->read($jd);

	// modify the object
	$jd['e-mail'] = '[email protected]';

	// save the changes
	$jd = $ripe->update($jd);
}
catch (RPSLException $e) {
	// errors regarding the setup of the RIPE object
}
catch (BadResponseException $e) {
	$errors = WebService::getErrors($e->getResponse()->getBody()));
}