PHPackages                             gotenberg/gotenberg-php - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. gotenberg/gotenberg-php

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

gotenberg/gotenberg-php
=======================

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

v2.23.0(3w ago)3856.2M↓30.3%2018MITPHPPHP ^8.1|^8.2|^8.3|^8.4|^8.5CI passing

Since Nov 28Pushed 1w ago4 watchersCompare

[ Source](https://github.com/gotenberg/gotenberg-php)[ Packagist](https://packagist.org/packages/gotenberg/gotenberg-php)[ Docs](https://github.com/gotenberg/gotenberg-php)[ GitHub Sponsors](https://github.com/gulien)[ RSS](/packages/gotenberg-gotenberg-php/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (40)Versions (47)Used By (18)

 [![Gotenberg PHP Logo](https://raw.githubusercontent.com/gotenberg/art/master/php-logo.png)](https://raw.githubusercontent.com/gotenberg/art/master/php-logo.png)

### Gotenberg PHP

[](#gotenberg-php)

A PHP client for interacting with Gotenberg

 [![Latest Version](https://camo.githubusercontent.com/10932c4d7088910c8553c5bd7c000d4d1f6cc7b2702187a35dfe0138415c2ddc/68747470733a2f2f706f7365722e707567782e6f72672f676f74656e626572672f676f74656e626572672d7068702f76)](https://packagist.org/packages/gotenberg/gotenberg-php) [![Total Downloads](https://camo.githubusercontent.com/106835f79c3072d6396a88d53a5310c5ec1b683bf4c2a21b246ece24dc2f15ef/68747470733a2f2f706f7365722e707567782e6f72672f676f74656e626572672f676f74656e626572672d7068702f646f776e6c6f616473)](https://packagist.org/packages/gotenberg/gotenberg-php) [![Monthly Downloads](https://camo.githubusercontent.com/cea15a1c07703d191ff7f361931500e04e44b3215492deffc13871638333f31b/68747470733a2f2f706f7365722e707567782e6f72672f676f74656e626572672f676f74656e626572672d7068702f642f6d6f6e74686c79)](https://packagist.org/packages/gotenberg/gotenberg-php) [![Continuous Integration](https://github.com/gotenberg/gotenberg-php/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/gotenberg/gotenberg-php/actions/workflows/continuous_integration.yml) [![https://codecov.io/gh/gotenberg/gotenberg](https://camo.githubusercontent.com/cfb3c778c1d4e8c8090f8f254f66bf7b23130eb58889852ae5d8634f41c012cd/68747470733a2f2f636f6465636f762e696f2f67682f676f74656e626572672f676f74656e626572672d7068702f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/gotenberg/gotenberg-php)

---

This package is a PHP client for [Gotenberg](https://gotenberg.dev), a developer-friendly API to interact with powerful tools like Chromium and LibreOffice for converting numerous document formats (HTML, Markdown, Word, Excel, etc.) into PDF files, and more!

Gotenberg versionClient`8.x` **(current)**`v2.x` **(current)**`7.x``v1.x``6.x`[thecodingmachine/gotenberg-php-client](https://github.com/thecodingmachine/gotenberg-php-client)Tip

A [Symfony Bundle](https://github.com/sensiolabs/GotenbergBundle) is also available!

Quick Examples
--------------

[](#quick-examples)

You may convert a target URL to PDF and save it to a given directory:

```
use Gotenberg\Gotenberg;

// Converts a target URL to PDF and saves it to a given directory.
$filename = Gotenberg::save(
    Gotenberg::chromium($apiUrl)->pdf()->url('https://my.url'),
    $pathToSavingDirectory
);
```

You may also convert Office documents:

```
use Gotenberg\Gotenberg;
use Gotenberg\Stream;

// Converts Office documents to PDF.
$response = Gotenberg::send(
    Gotenberg::libreOffice($apiUrl)
        ->convert(
            Stream::path($pathToDocx),
            Stream::path($pathToXlsx)
        )
);
```

Requirement
-----------

[](#requirement)

This packages requires [Gotenberg](https://gotenberg.dev), a containerized API for seamless PDF conversion.

See the [installation guide](https://gotenberg.dev/docs/getting-started/installation) for more information.

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

[](#installation)

This package can be installed with Composer:

```
composer require gotenberg/gotenberg-php

```

We use *PSR-7* HTTP message interfaces (i.e., `RequestInterface` and `ResponseInterface`) and the *PSR-18* HTTP client interface (i.e., `ClientInterface`).

For the latter, you may need an adapter in order to use your favorite client library. Check the available adapters:

-

If you're not sure which adapter you should use, consider using the `php-http/guzzle7-adapter`:

```
composer require php-http/guzzle7-adapter

```

Build a request
---------------

[](#build-a-request)

This package is organized around *modules*, namely:

```
use Gotenberg\Gotenberg;

Gotenberg::chromium($apiUrl);
Gotenberg::libreOffice($apiUrl);
Gotenberg::pdfEngines($apiUrl);
```

Each of these modules offers a variety of methods to populate a *multipart/form-data* request.

After setting all optional form fields and files, you can create a request by calling the method that represents the endpoint. For example, to call the `/forms/chromium/convert/url` route:

```
use Gotenberg\Gotenberg;

Gotenberg::chromium($apiUrl)
    ->pdf()                  // Or screenshot().
    ->singlePage()           // Optional.
    ->url('https://my.url'));
```

Tip

Head to the [documentation](https://gotenberg.dev/) to learn about all possibilities.

If the route requires form files, use the `Stream` class to create them:

```
use Gotenberg\DownloadFrom;
use Gotenberg\Gotenberg;
use Gotenberg\Stream;

Gotenberg::libreOffice($apiUrl)
    ->convert(Stream::path($pathToDocument));

// Alternatively, you may also set the content directly.
Gotenberg::chromium($apiUrl)
    ->pdf()
    ->assets(Stream::string('style.css', 'body{font-family: Arial, Helvetica, sans-serif;}'))
    ->html(Stream::string('index.html', 'Hello, world!'));

// Or create your stream from scratch.
Gotenberg::libreOffice($apiUrl)
    ->convert(new Stream('document.docx', $stream));

// Or even tell Gotenberg to download the files for you.
Gotenberg::libreOffice($apiUrl)
    ->downloadFrom([
        new DownloadFrom('https://url.to.document.docx', ['MyHeader' => 'MyValue'])
    ])
    ->convert();
```

Send a request to the API
-------------------------

[](#send-a-request-to-the-api)

After having created the HTTP request, you have two options:

1. Get the response from the API and handle it according to your need.
2. Save the resulting file to a given directory.

### Get a response

[](#get-a-response)

You may use any HTTP client that is able to handle a *PSR-7* `RequestInterface` to call the API:

```
use Gotenberg\Gotenberg;

$request = Gotenberg::chromium($apiUrl)
    ->pdf()
    ->url('https://my.url');

$response = $client->sendRequest($request);
```

If you have a *PSR-18* compatible HTTP client (see [Installation](#installation)), you may also use `Gotenberg::send`:

```
use Gotenberg\Gotenberg;

$request = Gotenberg::chromium($apiUrl)
    ->pdf()
    ->url('https://my.url');

try {
    $response = Gotenberg::send($request);
    return $response;
} catch (GotenbergApiErrored $e) {
    // $e->getResponse();
}
```

This helper will parse the response and if it is not **2xx**, it will throw an exception. That's especially useful if you wish to return the response directly to the browser.

You may also explicitly set the HTTP client:

```
use Gotenberg\Gotenberg;

$response = Gotenberg::send($request, $client);
```

### Save the resulting file

[](#save-the-resulting-file)

If you have a *PSR-18* compatible HTTP client (see [Installation](#installation)), you may use `Gotenberg::save`:

```
use Gotenberg\Gotenberg;

$request = Gotenberg::chromium($apiUrl)
    ->pdf()
    ->url('https://my.url');

$filename = Gotenberg::save($request, '/path/to/saving/directory');
```

It returns the filename of the resulting file. By default, Gotenberg creates a *UUID* filename (i.e., `95cd9945-484f-4f89-8bdb-23dbdd0bdea9`) with either a `.zip` or a `.pdf` file extension (or image formats for screenshots).

You may also explicitly set the HTTP client:

```
use Gotenberg\Gotenberg;

$response = Gotenberg::save($request, $pathToSavingDirectory, $client);
```

### Filename

[](#filename)

You may override the output filename with:

```
use Gotenberg\Gotenberg;

$request = Gotenberg::chromium($apiUrl)
    ->pdf()
    ->outputFilename('my_file')
    ->url('https://my.url');
```

Gotenberg will automatically add the correct file extension.

### Correlation ID

[](#correlation-id)

By default, Gotenberg creates a *UUID* correlation ID that identifies a request in its logs. You may override its value thanks to:

```
use Gotenberg\Gotenberg;

$request = Gotenberg::chromium($apiUrl)
    ->pdf()
    ->correlationId('debug')
    ->url('https://my.url');
```

It will set the header `Gotenberg-Trace` with your value. You may also override the default header name:

```
use Gotenberg\Gotenberg;

$request = Gotenberg::chromium($apiUrl)
    ->pdf()
    ->correlationId('debug', 'Request-Id')
    ->url('https://my.url');
```

Please note that it should be the same value as defined by the `--api-correlation-id-header` Gotenberg's property.

The response from Gotenberg will also contain the correlation ID header. In case of error, both the `Gotenberg::send`and `Gotenberg::save` methods throw a `GotenbergApiErrored` exception that provides the following method for retrieving it:

```
use Gotenberg\Exceptions\GotenbergApiErrored;
use Gotenberg\Gotenberg;

try {
    $response = Gotenberg::send(
        Gotenberg::chromium($apiUrl)
            ->screenshot()
            ->url('https://my.url')
    );
} catch (GotenbergApiErrored $e) {
    $correlationId = $e->getCorrelationId();
    // Or if you override the header name:
    $correlationId = $e->getCorrelationId('Request-Id');
}
```

Note

The `trace()` and `getGotenbergTrace()` methods are deprecated but still available for backward compatibility.

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance97

Actively maintained with recent releases

Popularity64

Solid adoption and visibility

Community35

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 86.2% 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 ~36 days

Recently: every ~19 days

Total

46

Last Release

21d ago

Major Versions

v0.1.4 → v1.0.02022-02-08

v1.1.8 → v2.0.02024-01-04

PHP version history (7 changes)v0.1.0PHP ^7.4|^8.0

v0.1.1PHP ^7.4|^8.0|^8.1

v1.1.1PHP ^7.4|^8.0|^8.1|^8.2

v1.1.6PHP ^7.4|^8.0|^8.1|^8.2|^8.3

v2.0.0PHP ^8.1|^8.2|^8.3

v2.10.1PHP ^8.1|^8.2|^8.3|^8.4

v2.15.1PHP ^8.1|^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/338af3713880f6fbb0d6ea8aacdca17fb856d6fe354de06b55d6d35e08b2b426?d=identicon)[gulnap](/maintainers/gulnap)

---

Top Contributors

[![gulien](https://avatars.githubusercontent.com/u/8983173?v=4)](https://github.com/gulien "gulien (106 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![dontfreakout](https://avatars.githubusercontent.com/u/1829574?v=4)](https://github.com/dontfreakout "dontfreakout (1 commits)")[![mariusjp](https://avatars.githubusercontent.com/u/1510476?v=4)](https://github.com/mariusjp "mariusjp (1 commits)")[![pieterocp](https://avatars.githubusercontent.com/u/68863060?v=4)](https://github.com/pieterocp "pieterocp (1 commits)")[![qdequippe](https://avatars.githubusercontent.com/u/3193300?v=4)](https://github.com/qdequippe "qdequippe (1 commits)")[![rreynier](https://avatars.githubusercontent.com/u/1953114?v=4)](https://github.com/rreynier "rreynier (1 commits)")[![Tugzrida](https://avatars.githubusercontent.com/u/11975357?v=4)](https://github.com/Tugzrida "Tugzrida (1 commits)")[![vidschofelix](https://avatars.githubusercontent.com/u/8752158?v=4)](https://github.com/vidschofelix "vidschofelix (1 commits)")[![AlexSkrypnyk](https://avatars.githubusercontent.com/u/378794?v=4)](https://github.com/AlexSkrypnyk "AlexSkrypnyk (1 commits)")[![yanbuatois](https://avatars.githubusercontent.com/u/33253657?v=4)](https://github.com/yanbuatois "yanbuatois (1 commits)")[![ChangingTerry](https://avatars.githubusercontent.com/u/5968506?v=4)](https://github.com/ChangingTerry "ChangingTerry (1 commits)")

---

Tags

chromiumconversioncsvdocxexcelgoogle-chromegotenberghtmllibreofficemarkdownpdfpdftkphppptxpuppeteerunoconvwkhtmltopdfwordxlsxpdfwkhtmltopdfconverthtmlexcelxlsxcsvmarkdownworddocxchromepuppeteerunoconvpptxchromiumpdftkLibreOfficeGotenberg

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gotenberg-gotenberg-php/health.svg)

```
[![Health](https://phpackages.com/badges/gotenberg-gotenberg-php/health.svg)](https://phpackages.com/packages/gotenberg-gotenberg-php)
```

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[anthropic-ai/sdk

Anthropic PHP SDK

163583.3k17](/packages/anthropic-ai-sdk)

PHPackages © 2026

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