{"id":13623402,"url":"https://github.com/gotenberg/gotenberg-php","last_synced_at":"2026-04-06T11:00:51.105Z","repository":{"id":43462306,"uuid":"431808004","full_name":"gotenberg/gotenberg-php","owner":"gotenberg","description":"🐘 A PHP client for interacting with Gotenberg.","archived":false,"fork":false,"pushed_at":"2026-03-31T12:13:50.000Z","size":235,"stargazers_count":369,"open_issues_count":0,"forks_count":21,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-02T05:04:17.750Z","etag":null,"topics":["chromium","conversion","csv","docx","excel","google-chrome","gotenberg","html","libreoffice","markdown","pdf","pdftk","php","pptx","puppeteer","unoconv","wkhtmltopdf","word","xlsx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotenberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["gulien"]}},"created_at":"2021-11-25T10:44:35.000Z","updated_at":"2026-04-01T04:06:58.000Z","dependencies_parsed_at":"2024-01-04T19:45:23.449Z","dependency_job_id":"72d6dd74-edb6-4de3-8417-0dcd0bfe2427","html_url":"https://github.com/gotenberg/gotenberg-php","commit_stats":{"total_commits":73,"total_committers":9,"mean_commits":8.11111111111111,"dds":0.1095890410958904,"last_synced_commit":"e8bc519812349f7bd57b294b4ea41dce53693b7c"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/gotenberg/gotenberg-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotenberg%2Fgotenberg-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotenberg%2Fgotenberg-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotenberg%2Fgotenberg-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotenberg%2Fgotenberg-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotenberg","download_url":"https://codeload.github.com/gotenberg/gotenberg-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotenberg%2Fgotenberg-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31469743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chromium","conversion","csv","docx","excel","google-chrome","gotenberg","html","libreoffice","markdown","pdf","pdftk","php","pptx","puppeteer","unoconv","wkhtmltopdf","word","xlsx"],"created_at":"2024-08-01T21:01:31.355Z","updated_at":"2026-04-06T11:00:51.064Z","avatar_url":"https://github.com/gotenberg.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/8983173/143772621-444a7bad-7a74-450a-a5b4-59af00c57d60.png\" alt=\"Gotenberg PHP Logo\" width=\"150\" height=\"140\" /\u003e\n    \u003ch3 align=\"center\"\u003eGotenberg PHP\u003c/h3\u003e\n    \u003cp align=\"center\"\u003eA PHP client for interacting with Gotenberg\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ca href=\"https://packagist.org/packages/gotenberg/gotenberg-php\"\u003e\u003cimg alt=\"Latest Version\" src=\"https://poser.pugx.org/gotenberg/gotenberg-php/v\" /\u003e\u003c/a\u003e\n        \u003ca href=\"https://packagist.org/packages/gotenberg/gotenberg-php\"\u003e\u003cimg alt=\"Total Downloads\" src=\"https://poser.pugx.org/gotenberg/gotenberg-php/downloads\" /\u003e\u003c/a\u003e\n        \u003ca href=\"https://packagist.org/packages/gotenberg/gotenberg-php\"\u003e\u003cimg alt=\"Monthly Downloads\" src=\"https://poser.pugx.org/gotenberg/gotenberg-php/d/monthly\" /\u003e\u003c/a\u003e\n        \u003ca href=\"https://github.com/gotenberg/gotenberg-php/actions/workflows/continuous_integration.yml\"\u003e\u003cimg alt=\"Continuous Integration\" src=\"https://github.com/gotenberg/gotenberg-php/actions/workflows/continuous_integration.yml/badge.svg\" /\u003e\u003c/a\u003e\n        \u003ca href=\"https://codecov.io/gh/gotenberg/gotenberg-php\"\u003e\u003cimg alt=\"https://codecov.io/gh/gotenberg/gotenberg\" src=\"https://codecov.io/gh/gotenberg/gotenberg-php/branch/main/graph/badge.svg\" /\u003e\u003c/a\u003e\n    \u003c/p\u003e\n\u003c/p\u003e\n\n---\n\nThis package is a PHP client for [Gotenberg](https://gotenberg.dev), a developer-friendly API to interact with powerful \ntools like Chromium and LibreOffice for converting numerous document formats (HTML, Markdown, Word, Excel, etc.) into \nPDF files, and more!\n\n| Gotenberg version   | Client                                                                                            |\n|---------------------|---------------------------------------------------------------------------------------------------|\n| `8.x` **(current)** | `v2.x` **(current)**                                                                              |\n| `7.x`               | `v1.x`                                                                                            |\n| `6.x`               | [thecodingmachine/gotenberg-php-client](https://github.com/thecodingmachine/gotenberg-php-client) |\n\n\u003e [!TIP]\n\u003e A [Symfony Bundle](https://github.com/sensiolabs/GotenbergBundle) is also available!\n\n## Quick Examples\n\nYou may convert a target URL to PDF and save it to a given directory:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n// Converts a target URL to PDF and saves it to a given directory.\n$filename = Gotenberg::save(\n    Gotenberg::chromium($apiUrl)-\u003epdf()-\u003eurl('https://my.url'), \n    $pathToSavingDirectory\n);\n```\n\nYou may also convert Office documents:\n\n```php\nuse Gotenberg\\Gotenberg;\nuse Gotenberg\\Stream;\n\n// Converts Office documents to PDF.\n$response = Gotenberg::send(\n    Gotenberg::libreOffice($apiUrl)\n        -\u003econvert(\n            Stream::path($pathToDocx),\n            Stream::path($pathToXlsx)\n        )\n);\n```\n\n## Requirement\n\nThis packages requires [Gotenberg](https://gotenberg.dev), a containerized API for seamless PDF conversion.\n\nSee the [installation guide](https://gotenberg.dev/docs/getting-started/installation) for more information.\n\n## Installation\n\nThis package can be installed with Composer:\n\n```\ncomposer require gotenberg/gotenberg-php\n```\n\nWe use *PSR-7* HTTP message interfaces (i.e., `RequestInterface` and `ResponseInterface`) and the *PSR-18* HTTP client\ninterface (i.e., `ClientInterface`).\n\nFor the latter, you may need an adapter in order to use your favorite client library. Check the available adapters:\n\n* https://docs.php-http.org/en/latest/clients.html\n\nIf you're not sure which adapter you should use, consider using the `php-http/guzzle7-adapter`:\n\n```\ncomposer require php-http/guzzle7-adapter\n```\n\n## Build a request\n\nThis package is organized around *modules*, namely:\n\n```php\nuse Gotenberg\\Gotenberg;\n\nGotenberg::chromium($apiUrl);\nGotenberg::libreOffice($apiUrl);\nGotenberg::pdfEngines($apiUrl);\n```\n\nEach of these modules offers a variety of methods to populate a *multipart/form-data* request.\n\nAfter setting all optional form fields and files, you can create a request by calling the method that represents the endpoint. \nFor example, to call the `/forms/chromium/convert/url` route:\n\n```php\nuse Gotenberg\\Gotenberg;\n\nGotenberg::chromium($apiUrl)\n    -\u003epdf()                  // Or screenshot().\n    -\u003esinglePage()           // Optional.\n    -\u003eurl('https://my.url'));\n```\n\n\u003e [!TIP]\n\u003e Head to the [documentation](https://gotenberg.dev/) to learn about all possibilities.\n\nIf the route requires form files, use the `Stream` class to create them:\n\n```php\nuse Gotenberg\\DownloadFrom;\nuse Gotenberg\\Gotenberg;\nuse Gotenberg\\Stream;\n\nGotenberg::libreOffice($apiUrl)\n    -\u003econvert(Stream::path($pathToDocument));\n\n// Alternatively, you may also set the content directly.\nGotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003eassets(Stream::string('style.css', 'body{font-family: Arial, Helvetica, sans-serif;}'))\n    -\u003ehtml(Stream::string('index.html', '\u003chtml\u003e\u003chead\u003e\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"\u003e\u003c/head\u003e\u003cbody\u003e\u003cp\u003eHello, world!\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e'));\n\n// Or create your stream from scratch.\nGotenberg::libreOffice($apiUrl)\n    -\u003econvert(new Stream('document.docx', $stream));\n\n// Or even tell Gotenberg to download the files for you.\nGotenberg::libreOffice($apiUrl)\n    -\u003edownloadFrom([\n        new DownloadFrom('https://url.to.document.docx', ['MyHeader' =\u003e 'MyValue'])\n    ])\n    -\u003econvert();\n```\n\n## Send a request to the API\n\nAfter having created the HTTP request, you have two options:\n\n1. Get the response from the API and handle it according to your need.\n2. Save the resulting file to a given directory.\n\n### Get a response\n\nYou may use any HTTP client that is able to handle a *PSR-7* `RequestInterface` to call the API:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$request = Gotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003eurl('https://my.url');\n\n$response = $client-\u003esendRequest($request);\n```\n\nIf you have a *PSR-18* compatible HTTP client (see [Installation](#installation)), you may also use `Gotenberg::send`:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$request = Gotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003eurl('https://my.url');\n\ntry {\n    $response = Gotenberg::send($request);\n    return $response;\n} catch (GotenbergApiErrored $e) {\n    // $e-\u003egetResponse();\n}\n```\n\nThis helper will parse the response and if it is not **2xx**, it will throw an exception. That's especially useful if \nyou wish to return the response directly to the browser.\n\nYou may also explicitly set the HTTP client:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$response = Gotenberg::send($request, $client);\n```\n\n### Save the resulting file\n\nIf you have a *PSR-18* compatible HTTP client (see [Installation](#installation)), you may use `Gotenberg::save`:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$request = Gotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003eurl('https://my.url');\n    \n$filename = Gotenberg::save($request, '/path/to/saving/directory');\n```\n\nIt returns the filename of the resulting file. By default, Gotenberg creates a *UUID* filename (i.e., \n`95cd9945-484f-4f89-8bdb-23dbdd0bdea9`) with either a `.zip` or a `.pdf` file extension (or image formats for screenshots).\n\nYou may also explicitly set the HTTP client:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$response = Gotenberg::save($request, $pathToSavingDirectory, $client);\n```\n\n### Filename\n\nYou may override the output filename with:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$request = Gotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003eoutputFilename('my_file')\n    -\u003eurl('https://my.url');\n```\n\nGotenberg will automatically add the correct file extension.\n\n### Correlation ID\n\nBy default, Gotenberg creates a *UUID* correlation ID that identifies a request in its logs. You may override its value\nthanks to:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$request = Gotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003ecorrelationId('debug')\n    -\u003eurl('https://my.url');\n```\n\nIt will set the header `Gotenberg-Trace` with your value. You may also override the default header name:\n\n```php\nuse Gotenberg\\Gotenberg;\n\n$request = Gotenberg::chromium($apiUrl)\n    -\u003epdf()\n    -\u003ecorrelationId('debug', 'Request-Id')\n    -\u003eurl('https://my.url');\n```\n\nPlease note that it should be the same value as defined by the `--api-correlation-id-header` Gotenberg's property.\n\nThe response from Gotenberg will also contain the correlation ID header. In case of error, both the `Gotenberg::send`\nand `Gotenberg::save` methods throw a `GotenbergApiErrored` exception that provides the following method for retrieving\nit:\n\n```php\nuse Gotenberg\\Exceptions\\GotenbergApiErrored;\nuse Gotenberg\\Gotenberg;\n\ntry {\n    $response = Gotenberg::send(\n        Gotenberg::chromium($apiUrl)\n            -\u003escreenshot()\n            -\u003eurl('https://my.url')\n    );\n} catch (GotenbergApiErrored $e) {\n    $correlationId = $e-\u003egetCorrelationId();\n    // Or if you override the header name:\n    $correlationId = $e-\u003egetCorrelationId('Request-Id');\n}\n```\n\n\u003e [!NOTE]\n\u003e The `trace()` and `getGotenbergTrace()` methods are deprecated but still available for backward compatibility.\n","funding_links":["https://github.com/sponsors/gulien"],"categories":["Table of Contents","Clients"],"sub_categories":["PDF"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotenberg%2Fgotenberg-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotenberg%2Fgotenberg-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotenberg%2Fgotenberg-php/lists"}