Installation

The PHP SDK is hosted here. To install the bindings via Composer, add the following to composer.json to list the repository as a source:

1"repositories": [
2 {
3 "type": "vcs",
4 "url": "https://github.com/SchematicHQ/schematic-php.git"
5 }
6 ]

Then, run the following:

$composer require schematichq/schematic-php

Initialization

Initialize a client with an API key secret.

1use Schematic;
2
3$schematic_companies = new Schematic\Api\CompaniesApi(Schematic\Configuration::getDefaultConfiguration()
4 ->setApiKey('X-Schematic-Api-Key', "sch_dev_yourapikey"))

That will create an instance of schematic_companies that you can use to interact with the initialized resource. Other resources can be initialized in a similar manner.

Usage example

Once the SDK is initialized, you may submit requests. Below is an example of upserting a Company (creating or updating it).

1try {
2 $schematic_companies->createCompany([
3 "keys" => [
4 "id" => $this->id,
5 ],
6 "name" => $this->name,
7 "traits" => [
8 "uuid" => $this->uuid,
9 "account_id" => $this->account_id,
10 "subscription_tier" => $this->subscription_tier,
11 "subscription_quantity" => $this->subscription_quantity,
12 "trial_end_time" => $this->trial_end_time,
13 ],
14 ]);
15} catch (\Exception $e) {
16 report($e);
17}