glhd/linearavel

0.0.1 2024-03-18 02:17 UTC

This package is auto-updated.

Last update: 2024-04-19 16:04:37 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

Each call returns 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.

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