An object-oriented PHP wrapper for the Worksome API

Fund package maintenance!
worksome

v0.1.1 2023-05-31 13:41 UTC

This package is auto-updated.

Last update: 2024-06-13 11:33:40 UTC


README

Latest Version on Packagist Software License Build Status Static Analysis Status Total Downloads

An object-oriented PHP wrapper for the Worksome API

Requirements

Install

Via Composer

composer require worksome/sdk guzzlehttp/guzzle:^7.5 http-interop/http-factory-guzzle:^1.2

We are decoupled from any HTTP messaging client with help by HTTPlug.

Usage

Basic usage

// Include the Composer autoloader
require_once __DIR__ . '/vendor/autoload.php';

$client = new \Worksome\Sdk\Client();
$repositories = $client->graph()->execute(<<<GQL
    query {
        profile {
            name
            email
        }
    }
>>>);

Authentication

The Worksome SDK supports authenticating through an API token.

$client = new \Worksome\Sdk\Client();
$client->authenticate($apiToken);

Using a different HTTP client

Thanks to HTTPlug, we support the use of many HTTP clients. For example, to use the Symfony HTTP Client, first install the client and PSR-7 implementation.

composer require worksome/sdk symfony/http-client nyholm/psr7

Next, set up the Worksome client with this HTTP client:

$client = \Worksome\SDK\Client::createWithHttpClient(
    new \Symfony\Component\HttpClient\HttplugClient()
);

Alternatively, you can inject an HTTP client through the Client constructor.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

composer test

To update the test snapshots, set the WORKSOME_LOCAL_API_URL and WORKSOME_LOCAL_API_TOKEN environment variables, and then run composer update:snapshots.

Credits

License

The MIT License (MIT). Please see License File for more information.