A modern, strongly typed PHP client for the Atlassian Confluence Cloud REST API v2.
Generated directly from Atlassian's official OpenAPI specification, the library provides complete API coverage while remaining PSR-18 compatible, allowing it to work with Symfony HttpClient, Guzzle, HTTPlug-compatible clients, and other PSR implementations.
- Complete Confluence Cloud REST API v2 coverage
- Generated from Atlassian's official OpenAPI specification
- Strongly typed request and response models
- PSR-18 HTTP client support
- PSR-17 request and stream factories
- Lazy pagination helpers
- No framework dependency
- PHP 8.3+
composer require virtuallast/confluence-v2-php-client \
symfony/http-client \
nyholm/psr7The package depends only on PSR interfaces. Any PSR-18 client and PSR-17 implementation may be used.
use VirtualLast\ConfluenceV2\Configuration;
use VirtualLast\ConfluenceV2\ConfluenceClient;
$client = ConfluenceClient::create(
new Configuration(
baseUrl: 'https://your-company.atlassian.net',
email: 'confluence-user@example.com',
apiToken: $_ENV['CONFLUENCE_API_TOKEN'],
),
);
$page = $client->pages()->getPageById('123456');
echo $page->getTitle();$pages = $client->pages()->getPages([
'space-id' => ['12345'],
'limit' => 50,
]);
foreach ($pages->results as $page) {
echo $page->getTitle(), PHP_EOL;
}Every paginated endpoint also exposes an iterator.
foreach ($client->pages()->iteratePages([
'limit' => 50,
]) as $page) {
echo $page->getTitle(), PHP_EOL;
}Pagination follows Confluence cursor links automatically while validating that the next page remains on the configured Confluence instance.
Write operations use generated request models.
use VirtualLast\ConfluenceV2\Generated\Model\PagesPostBody;
use VirtualLast\ConfluenceV2\Generated\Model\PageBodyWrite;
$body = (new PageBodyWrite())
->setRepresentation('storage')
->setValue('<p>Hello from PHP</p>');
$request = (new PagesPostBody())
->setSpaceId('12345')
->setStatus('current')
->setTitle('Generated page')
->setBody($body);
$page = $client->pages()->createPage($request);The supplied baseUrl should be the Confluence site root, for example:
https://company.atlassian.net
The client automatically targets:
/wiki/api/v2
Authentication uses Atlassian email address and API token via HTTP Basic Authentication.
API tokens are automatically redacted from exception messages and debugging output.
Applications using a dependency injection container can provide their own PSR services.
$client = ConfluenceClient::create(
$configuration,
$psr18Client,
$psr17RequestFactory,
$psr17StreamFactory,
);If omitted, php-http/discovery locates suitable implementations automatically.
- HTTP responses outside the successful range throw
ApiException. - Transport failures throw
TransportException.
The library deliberately performs no retries. Retry behaviour should be configured by the injected HTTP client.
The client exposes resource APIs including:
- Pages
- Spaces
- Attachments
- Comments
- Users
- Blog Posts
…and every other resource defined in the Confluence Cloud REST API v2 specification.
The OpenAPI specification is committed to the repository together with all generated source code.
To update the specification:
php bin/console confluence:update-specTo regenerate the client:
php bin/console confluence:generateEquivalent Composer aliases are available:
composer update-spec
composer generate
composer run validateGenerated files should never be edited manually.
MIT