This is a PHP client library for the Global Registry
This repository uses the git-flow branching model. Please do development on the develop branch.
Use of the Global Registry PHP Client is through Composer.
Create or edit composer.json and add the following
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/GlobalTechnology/global-registry-php-client"
}
],
"require": {
"globaltechnology/global-registry-php-client": "dev-develop"
}
}
From the command line, install composer and required packages.
# Install Composer
curl -sS https://getcomposer.org/installer | php
# Install Packages
php composer.phar install
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
<?php
require 'vendor/autoload.php';
$client = \GlobalTechnology\GlobalRegistry\Client::factory( array(
'base_url' => '__GLOBAL_REGISTRY_URL__',
'access_token' => '__ACCESS_TOKEN__',
) );
// Create Entity
$entity = $client->createEntity( new \GlobalTechnology\GlobalRegistry\Model\Entity( 'person', array(
'first_name' => 'John',
'last_name' => 'Doe',
'address' => array( 'country' => 'US' ),
'client_integration_id' => '1',
) ) );
// Get an Entity
$entity = $client->getEntity( 7178632 );
// Update an Entity
$entity->last_name = 'TestUser';
$entity = $client->updateEntity( $entity );
// Add a Relationship
$entity->addRelationship( new \GlobalTechnology\GlobalRegistry\Model\Relationship( 'ministry', array(
'ministry' => '8edc2ad4-d6ac-11e3-851c-12725f8f377c',
'client_integration_id' => 2,
'ministry_of_employment' => true,
'funding_source' => 'Centrally Funded Staff'
) ) );
// Delete an Entity
$client->deleteEntity( $entity->id );
// Search for Entities
$entities = $client->getEntities( 'person', array( 'first_name' => 'john', 'address' => array( 'country' => 'UK' ) ) );
// $entities instanceof \GlobalTechnology\GlobalRegistry\Model\EntityCollection
foreach( $entities as $entity ) {
echo "{$entity->first_name} {$entity->last_name}";
}
if($entities->hasMore())
$entities = $entities->nextPage();