PHPackages                             cx-reports/api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. cx-reports/api-client

ActiveLibrary[API Development](/categories/api)

cx-reports/api-client
=====================

A client for interacting and downloading reports from the CxReports

0.0.5(2mo ago)05MITPHPPHP ^8.1

Since Feb 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/cx-reports/api-client-php)[ Packagist](https://packagist.org/packages/cx-reports/api-client)[ RSS](/packages/cx-reports-api-client/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

CxReports PHP Library
=====================

[](#cxreports-php-library)

A PHP client for the [CxReports](https://cx-reports.com) API. Generate reports synchronously or asynchronously, manage themes and templates, drive job runs, and embed previews — all behind a small typed surface backed by Guzzle.

Features
--------

[](#features)

- Bearer-token authentication
- List reports, report types, report pages, themes, templates, workspaces
- Synchronous PDF download (query params or JSON body)
- Asynchronous export flow (start → poll status → download content) with multiple document formats: PDF, DOCX, XLSX, PPTX, HTML
- Job runs: start, get status, generate review documents, deliver entries
- Nonce-protected preview URLs for iframe embedding
- Temporary data upload for large parameter payloads
- Consistent error model — every method throws `\Exception` with the full server response body on failure

Requirements
------------

[](#requirements)

- PHP 8.1 or newer (the library uses native enums)
- [Composer](https://getcomposer.org/)

Installation
------------

[](#installation)

```
composer require cx-reports/api-client
```

Quickstart
----------

[](#quickstart)

```
require 'vendor/autoload.php';

use CxReports\Client\CxReportsClient;

$client = new CxReportsClient(
    'https://your-tenant.cx-reports.app',
    'your-workspace-id-or-code',
    'your-personal-access-token'
);
```

The third argument is a Personal Access Token. Generate one from your CxReports account settings.

Usage
-----

[](#usage)

### List reports

[](#list-reports)

```
use CxReports\Models\Report;

$reports = $client->listReports('invoice');
foreach ($reports as $report) {
    echo $report->name . "\n";   // $report is a Report instance
}
```

### Download a PDF (GET — small payloads via query string)

[](#download-a-pdf-get--small-payloads-via-query-string)

```
$result = $client->downloadPdf('497', [
    'params' => ['number' => 123],
    'timezone' => 'Europe/Belgrade',
]);

file_put_contents($result->fileName, $result->pdf);
```

You can also target a different workspace per call:

```
$result = $client->downloadPdf('149', [], 'another-workspace');
```

### Download a PDF (POST — large or sensitive payloads)

[](#download-a-pdf-post--large-or-sensitive-payloads)

```
use CxReports\Models\ReportExportRequest;

$body = new ReportExportRequest([
    'params' => ['number' => 123],
    'data'   => $largeArrayOrObject,
    'theme'  => 'corporate',
]);

$result = $client->downloadPdfWithData('497', $body);
```

### Asynchronous export

[](#asynchronous-export)

For long-running reports or non-PDF formats, kick off an async generation, poll status, then download the file:

```
use CxReports\Models\AsyncReportGenerationRequest;
use CxReports\Models\DocumentFileFormat;

$start = $client->startExport('497', new AsyncReportGenerationRequest([
    'params' => ['number' => 123],
    'format' => DocumentFileFormat::xlsx,
]));

$tempFileId = $start->temporaryFileId;

do {
    sleep(1);
    $status = $client->getAsyncExportStatus($tempFileId);
    if ($status->status === 'Failed') {
        throw new \RuntimeException($status->errorMessage ?? 'Async export failed');
    }
} while (!$status->isReady);

$file = $client->getAsyncExportContent($tempFileId);
file_put_contents($file->fileName, $file->pdf);
```

### Listing report pages

[](#listing-report-pages)

```
use CxReports\Models\ReportPageType;

$pages = $client->listReportPages('497');
foreach ($pages as $page) {
    if ($page->type === ReportPageType::Subreport) {
        // handle subreport
    }
}
```

### Embedded preview URLs

[](#embedded-preview-urls)

```
$url = $client->getReportPreviewURL('497', [
    'params' => ['number' => 123],
    'data'   => $jsonPayload,     // converted to a tempDataId automatically
]);

// drop $url into an
```

### Themes and templates

[](#themes-and-templates)

```
$themes    = $client->getThemes();      // ReportThemeListItem[]
$templates = $client->getTemplates();   // ReportTemplate[]
```

### Job runs

[](#job-runs)

```
use CxReports\Models\JobRunRequest;

$jobs = $client->listJobs();

$run = $client->startNewJobRun('daily-invoices', new JobRunRequest([
    'params' => ['date' => '2026-05-29'],
]));

$status = $client->getJobRunStatus('daily-invoices', $run->jobRunId);

if ($status->finished) {
    $review = $client->generateJobRunReviewDocument('daily-invoices', $run->jobRunId);
    $client->deliverAllJobRunEntries('daily-invoices', $run->jobRunId);
}
```

### Workspaces

[](#workspaces)

```
$workspaces = $client->getWorkspaces();
```

Error handling
--------------

[](#error-handling)

Every client method throws `\Exception` on failure. The message includes the HTTP error and — when present — the full unredacted server response body, which is invaluable for debugging validation errors:

```
try {
    $client->downloadPdf('does-not-exist');
} catch (\Exception $e) {
    error_log($e->getMessage());
    // "Error downloading PDF: Client error: ... 404 Not Found
    //  Response body: {"type":"...","title":"Report not found",...}"
}
```

Tests
-----

[](#tests)

See [TESTS.md](TESTS.md). The test suite includes one offline unit check and a live integration set that is gated on environment variables — copy `.env.example` to `.env` and fill in your tenant before running.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

Support
-------

[](#support)

Open an issue on GitHub or email .

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance84

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 93.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~458 days

Total

2

Last Release

81d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45719288?v=4)[Ognjen Stefanovic](/maintainers/ognjenst)[@ognjenst](https://github.com/ognjenst)

---

Top Contributors

[![ognjenst](https://avatars.githubusercontent.com/u/45719288?v=4)](https://github.com/ognjenst "ognjenst (29 commits)")[![jelic-nikola](https://avatars.githubusercontent.com/u/212342873?v=4)](https://github.com/jelic-nikola "jelic-nikola (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cx-reports-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/cx-reports-api-client/health.svg)](https://phpackages.com/packages/cx-reports-api-client)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k55](/packages/neuron-core-neuron-ai)[files.com/files-php-sdk

Files.com PHP SDK

2482.9k](/packages/filescom-files-php-sdk)[volcengine/volcengine-php-sdk

119.5k](/packages/volcengine-volcengine-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
