sharemat / php-sdk
PHP SDK for Sharemat REST API
Installs: 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Type:package
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- nyholm/psr7: ^1.3
- symfony/http-client: ^5.1
Requires (Dev)
- phpunit/phpunit: ^9
- symfony/dotenv: ^5.1
This package is auto-updated.
Last update: 2024-04-25 15:12:14 UTC
README
PHP client for connecting to the Sharemat REST API.
Requirements
- PHP 7.0 or greater
- cUrl extension enabled
Installation
Use the following Composer command to install the SDK.
$ composer require sharemat/php-sdk $ composer update
Namespace
All the examples below assume the Sharemat\Php\Sdk\Api
class is imported
into the scope with the following namespace declaration:
use Sharemat\Sdk\Api;
Configuration
Provide your credentials to the dot env variables to prepare the API client for connecting to a store on the Sharemat platform:
Dot env
SHAREMAT_API_HOSTNAME=http://api.sharemat.local SHAREMAT_API_ACCESS_TOKEN=12345
Accessing collections and resources (GET)
To list all the resources in a collection:
$api = new Api(); $equipments = $api->equipment()->getEquipments(); foreach ($equipments as $equipment) { echo $equipment->name; }
To access a single resource and its connected sub-resources:
$api = new Api(); $equipment = $api->equipment()->getEquipment(1); echo $equipment->name;