An API client for the blob.build API written in PHP. This client is a combination of code generated by OpenAPI Generator and some wrappers around it to improve the usability.
The generated code can be found in src/Api
and src/Model
. It is recommended
to use the Wrappers in src/Client
instead of the generated code.
Install the package via composer:
composer require aternos/blob-build-api
The main entry point for the API is the BlobBuildAPIClient
class.
<?php
use Aternos\BlobBuild\Client\BlobBuildAPIClient;
// create an API client. This is the main entry point for the API
$client = new BlobBuildAPIClient();
// set a user agent (recommended)
$client->setUserAgent('aternos/php-blob-build-api-example');
You can list all projects using the listProjects
method.
$projects = $client->listProjects();
foreach ($projects as $project) {
echo "Project " . $project->getData()->getName() . " by " . $project->getData()->getOwner() . PHP_EOL;
}
To search for projects, you can use the searchProjects
method with a search query.
$projects = $client->searchProjects("sound");
foreach ($projects as $project) {
echo "Project " . $project->getData()->getName() . " by " . $project->getData()->getOwner() . PHP_EOL;
}
To fetch a specific project, you can use the getProject
method with the project's name.
$project = $client->getProject("SoundMuffler");
echo "Project " . $project->getData()->getName() . PHP_EOL;
Unlike the projects retrieved from listProjects
and searchProjects
, this method does not contain the project owner.
You can list all builds for a project using the getProjectBuilds
method with the project's name. This returns an array
where the keys are the name of a release channel and the values are arrays of builds for that channel.
$result = $client->getProjectBuilds("SoundMuffler");
foreach ($result as $channel => $builds) {
echo "Channel: " . $channel . PHP_EOL;
foreach ($builds as $build) {
echo " - Build " . $build->getData()->getBuildId() . PHP_EOL;
}
}
// or with the project wrapper
$project = $client->getProject("SoundMuffler");
$result = $project->getBuilds();
You can also fetch the latest build for a project in a specific channel.
$build = $client->getLatestProjectBuildInChannel("SoundMuffler", "Dev");
echo "Build " . $build->getData()->getBuildId() . PHP_EOL;
// Or with the project wrapper
$project = $client->getProject("SoundMuffler");
// Either pick a channel
$build = $project->getLatestBuildInChannel("Dev");
// Or use the default channel
$build = $project->getLatestBuildInDefaultChannel()
$build = $client->getProjectBuild("SoundMuffler", "Dev", 1);
echo "Build " . $build->getData()->getBuildId() . PHP_EOL;
// Or with the project wrapper
$project = $client->getProject("SoundMuffler");
$build = $project->getBuild("Dev", 1);
The generated code can be updated by installing the openapi generator and running the following command:
openapi-generator-cli generate -c config.yaml