The PHP SDK for interacting with the VHosting Tools API, developed using the Saloon library.
You can install the package via composer:
composer require vhosting/tools-sdkThe package automatically registers itself in Laravel through the Service Provider.
You can publish the configuration file with the following command:
php artisan vendor:publish --provider="VHosting\ToolsSdk\ToolsSdkServiceProvider"These are the supported environment variables:
TOOLS_TOKEN=your-api-token
TOOLS_URL=https://tools.vhosting-it.com
TOOLS_MOCK=falseThe token can be generated by visiting https://tools.vhosting-it.com/token.
The SDK provides a Laravel Facade that makes it easy to access resources.
All workflow operations are accessible via ToolsSdk::workflow().
use VHosting\ToolsSdk\Facades\ToolsSdk;
$paginator = ToolsSdk::workflow()->all();
foreach ($paginator as $workflow) {
echo $workflow->id;
echo $workflow->status;
}$workflow = ToolsSdk::workflow()->get(123);
echo $workflow->description;
echo $workflow->tasks_count;$workflow = ToolsSdk::workflow()->dispatch('workflow-type-name', [
'parameter1' => 'value1',
'parameter2' => 'value2',
]);
echo $workflow->id;ToolsSdk::workflow()->retry(123);The SDK integrates Saloon's faking system to facilitate testing:
use VHosting\ToolsSdk\Facades\ToolsSdk;
use Saloon\Http\Faking\MockResponse;
ToolsSdk::fake([
'*' => MockResponse::make(['id' => 1, 'status' => 'completed'], 200),
]);It is also possible to enable mocks globally via the TOOLS_MOCK=true environment variable, which will use the default data defined in the Mocks class.
MIT License (MIT). For more information, please see the LICENSE file.