Skip to content

glhd/linearavel

Repository files navigation

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');

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages