The Rebilly SDK for PHP makes it easy for developers to access Rebilly REST APIs in their PHP code.
- PHP 8.0+.
- CURL (verify peer requires a root certificate authority -- if you have not configured php curl to use one, and your system libs aren't linked to one, you may need to do a manual configuration to use the appropriate certificate authority)
Warning
This package does not follow semantic versioning, so minor version updates can cause backward compatibility breaks. Updates to the package should be tested before switching versions.
Using Composer is the recommended way to install the Rebilly SDK for PHP. To get started, you need run the Composer commands (assume you're in the project's root directory).
- Install the latest stable version of the SDK:
composer require rebilly/client-php
You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.
The previous version of the SDK can be outdated and won't provide all (or the correct) specifications to communicate with the REST APIs. Only the latest version is constantly supported.
Version | Supported | Documentation |
---|---|---|
2.x | ✅ See tab PHP-SDK-2.0 | |
3.x | ✅ (current) | ✅ See tab PHP |
Create a Rebilly Client
use Rebilly\Sdk\Client;
use Rebilly\Sdk\Service;
// Instantiate Rebilly client.
$client = new Client([
'baseUrl' => Client::SANDBOX_HOST,
'organizationId' => '{organizationId}',
'apiKey' => '{secretKey}',
]);
$service = new Service(client: $client);
Create a Customer
use Rebilly\Sdk\Exception\DataValidationException;
use Rebilly\Sdk\Model\ContactObject;
use Rebilly\Sdk\Model\Customer;
$customer = Customer::from([])
->setWebsiteId('{websiteId}')
->setPrimaryAddress(
ContactObject::from([])
->setFirstName('John')
->setLastName('Doe'),
);
try {
$customer = $service->customers()->create($form);
} catch (DataValidationException $e) {
var_dump($e->getValidationErrors());
}
For more see examples directory.
Read Rebilly REST APIs documentation for more details.
This new major version brings several new helper classes to communicate with Rebilly REST APIs and some incompatibilities that should be tested before switching SDK versions.
-
Now, a
Service
class can be explicitly instantiated to make the API calls instead of using only theClient
, as it encapsulates the API calls. -
To simplify the migration from the previous version, the
Client
object can be used to make calls to any API directly. For example, instead of instantiating a service class, one can use:$client->customers()->create($form);
-
The namespace changed from
Rebilly\Entities
toRebilly\Sdk\Model
. Now, thesrc
isRebilly\Sdk
. -
The classes are now generated by an automated process that is triggered every time a new version of the API definitions is released. It means more frequency on the SDK updates, keeping it synced with the REST APIs.