wqa/php-gitbook

A PHP wrapper for the Gitbook API.

v1.0.0 2021-03-17 16:19 UTC

This package is auto-updated.

Last update: 2024-11-18 18:38:53 UTC


README

Note that The GitBook API is still in beta, so the underlying API and this wrapper are subject to change.

Install

composer require wqa/php-gitbook

Usage

Create a client

$gitbook = new GitbookClient($secretKey);

Get the current user

$gitbook->getCurrentUser();

Get user

$gitbook->getUser($userUid);

Get spaces for current user

$gitbook->getSpaces();

Get spaces for specific user or organisation

$gitbook->getSpacesFor($userUid);
$gitbook->getSpacesFor($organisationUid);

Get space

$gitbook->space($spaceUid)->get();

Get space revision

$gitbook->space($spaceUid)->primaryRevision()->get();
$gitbook->space($spaceUid)->revision($revisionUid)->get();

Get space draft revision

$gitbook->space($spaceUid)->draft($draftUid)->get();

Get space variant

$gitbook->space($spaceUid)->primaryRevision()->getVariant();
$gitbook->space($spaceUid)->primaryRevision()->getVariant('spanish');

Get page content

$gitbook->space($spaceUid)->primaryRevision()->getPage($pageUid);
$gitbook->space($spaceUid)->primaryRevision()->getPageByUrl($pageUrl);

// Get page content for variant
$gitbook->space($spaceUid)->primaryRevision()->getPage($pageUid, 'spanish');
$gitbook->space($spaceUid)->primaryRevision()->getPageByUrl($pageUrl, 'spanish');

// Get page content as markdown
$gitbook->space($spaceUid)->primaryRevision()->getPage($pageUid, 'master', PageFormat::Markdown);
$gitbook->space($spaceUid)->primaryRevision()->getPageByUrl($pageUrl, 'master', PageFormat::Markdown);

Get space assets

$gitbook->space($spaceUid)->primaryRevision()->getAssets();