glhd/linearavel

0.0.3 2024-06-26 21:04 UTC

This package is auto-updated.

Last update: 2024-12-05 18:42:22 UTC


README

Build Status Coverage Status Latest Stable Release MIT Licensed Follow @inxilpro on Twitter

Linearavel

Linearavel is a fully-featured Linear SDK for PHP and Laravel.

Installation

composer require glhd/linearavel

Usage

Linear uses GraphQL which tends not to be particularly compatible with how PHP applications interact with APIs. This package attempts to bridge that gap—making API calls feel fluent but still exposing all the power of the Linear API.

A typical API call will look something like:

$viewer = Linear::viewer() // "viewer" is the name of the GraphQL query
    ->with('organization', 'id', 'name') // `with` lets you quickly retrieve nested fields
    ->get('id', 'name', 'active', 'avatarUrl', 'timezone'); // `get` defines the fields to retrieve

Calling get() will give you the query results directly. You can also call response() to get a LinearResponse—a custom Saloon object that exposes things like status() and headers() as well as letting you resolve() the response into a fully-typed Linear data object.

assert($viewer instanceof Glhd\Linearavel\Data\User);
assert($viewer->name === 'Chris Morrell');
assert($viewer->organization instanceof Glhd\Linearavel\Data\Organization);
assert($viewer->organization->name === 'InterNACHI');