vivait / docbuild-php
PHP client for doc.build
Installs: 25 592
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 9
Forks: 2
Open Issues: 0
Requires
- php: >=7.4
- ext-json: *
- psr/http-message: ^1.0
Requires (Dev)
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^7.4
README
Installation
composer require vivait/docbuild-php
and then write an Adapter that's compatible with the Adapter interface.
Usage
See Doc.Build's Api documentation for detailed information on its methods.
The class requires your client id, client secret and a compatible Adapter.
// Instantiate your adapter $client = new MyAdapter(); $docBuild = new DocBuild($clientId, $clientSecret, $client); $docBuild->createDocument('ADocument', 'docx', '/path/to/file.docx'); $docs = $docBuild->getDocuments(); $docBuild->convertToPdf('documentid', 'http://mycallback.url/api');
Caching
This library uses the doctrine/cache
library to cache access_token
between
requests. By default it will use the Doctrine\Common\Cache\FilesystemCache
,
but this can be changed by injecting a cache that implements
Doctrine\Common\Cache\Cache
into the constructor:
$docBuild = new DocBuild( $clientId, $clientSecret, GuzzleAdapter::createWithConfig([]), $options, null, new ArrayCache() );
Manually refresh access_token
By default, the client will automatically refresh your access_token
. However,
this behaviour can be changed by setting the following option, or passing this
options array into the constructor on instantiation.
$docBuild->setOptions( [ 'token_refresh' => false, // Default: true ] ); try { $docs = $docBuild->getDocuments(); } catch (TokenExpiredException $e) { // Have another go }