The Lagoon PHP SDK enables PHP developers to interact easily with the Lagoon GraphQL API in their PHP applications.
Getting started
- Have your access token and lagoon endpoint handy
- Install the SDK with composer
Requirements
Lagoon PHP SDK requires PHP 7 or greater on your machine.
Installation
Composer
Add the SDK as a dependency to your project.
$ composer require steveworley/lagoon-php-sdk
Client Overview
The SDK provides the LagoonClient
object which is the main entry point into the Lagoon API. The client has methods which relate to different operations of the API and can all be accessed publicly. Each operation has a number of queries or mutations that will be exposed via methods.
Example all projects
For example: Querying for all projects
- Access the
projects()
operations of aLagoonClient
instance. - Access the
all()
task of the project operation. execute()
the task
$client = new LagoonClient($endpoint, $token);
$projects = $client->projects()->all()->execute()
Example all projects with fields
Each task has a default list of fields it will request from the API (in most cases this will be id
) you can override the fields that will be request to return more information from GraphQL.
For example: Get the names of all projects
- Access the
projects()
operations of aLagoonClient
instance. - Access the
all()
task of the project operation. - Request additional
fields()
from the task execute()
the task
$client = new LagoonClient($endpoint, $token);
$projects = $client->projects()->all()->fields(['id', 'name'])->execute()