glhd / linearavel
0.0.3
2024-06-26 21:04 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- illuminate/support: ^9|^10|11.x-dev|dev-master
- nikic/php-parser: ^5.0
- saloonphp/saloon: ^3.0
- spatie/laravel-data: ^4.2
- webonyx/graphql-php: ^15.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.34
- mockery/mockery: ^1.6
- orchestra/testbench: ^6.24|^7.10|^8|9.x-dev|10.x-dev|dev-master
- phpunit/phpunit: ^10.3
README
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');