---
type: Article
title: Use Marqius Kern with PHP, Laravel and Symfony | Marqius
description: Step-by-step examples for gotenberg-php 2 and 3, the Symfony bundle
  and Laravel PDF, including known differences.
resource: https://marqius.com/blog/php-laravel-symfony-marqius-kern/
tags:
  - marqius
  - journal
status: stable
sources:
  - id: official-page
    resource: https://marqius.com/blog/php-laravel-symfony-marqius-kern/
    last_modified: 2026-12-02T08:19:13.762Z
generated:
  by: process:marqius-site-build
  at: 2026-12-02T08:32:12.045Z
x_marqius:
  language: en
  source_sha256: 9d9f53a0d729a1206f693442935e634039d413163843bff0f91176d1969fe21e
  extraction: public-main-content
---

Marqius Kern developers

# Use Marqius Kern with PHP, Laravel and Symfony

gotenberg-php, the Symfony bundle and laravel-pdf call Gotenberg's API at the address you give them. Marqius Kern answers that API, Gotenberg 8's and 9's on one server, from a 41 MB image: change the image your compose file or manifest runs, and your PHP code stays as it is.

Marqius December 2, 2026

[Try it](https://marqius.com/blog/php-laravel-symfony-marqius-kern/#gotenberg-php-2-and-3-each-in-one-folder) · [Review compatibility results](https://marqius.com/blog/php-laravel-symfony-marqius-kern/#compatibility-results)

The container image to use in your Compose file or deployment manifest:

text

```
image: marqius/kern
```

* * *

## gotenberg-php 2 and 3, each in one folder.

gotenberg-php calls the address you pass to `Gotenberg::chromium()`, `Gotenberg::libreOffice()` and `Gotenberg::pdfEngines()` (`Gotenberg::pdf()` in version 3); that address stays as it is. Version 2 speaks Gotenberg 8's API, version 3 Gotenberg 9's; Marqius Kern answers both. Follow the part for the version you use.

### Version 2, for Gotenberg 8

**You need:** Docker, curl, PHP 8.1 or later and Composer.

**It takes:** about 5 minutes.

#### Step 1. Start Marqius Kern

In a new, empty folder, start Marqius Kern and wait until it answers. The first command starts it in the background, as a container named `kern` on port 3000; the second asks its health check until it answers.

bash

```
docker run --rm -d --name kern -p 3000:3000 marqius/kern
curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/health
```

**You should see:** a long string of letters and digits (the container's ID), then a line that begins `{"status":"up"`.

#### Step 2. Install the client

This installs version 2.27.0, with Guzzle as its HTTP client, as the library's own guide advises. If Composer asks whether to trust `php-http/discovery`, either answer works here.

bash

```
composer require gotenberg/gotenberg-php:2.27.0 php-http/guzzle7-adapter:1.1.0
```

**You should see:** Composer list each package it installs, among them `- Installing gotenberg/gotenberg-php (v2.27.0): Extracting archive`.

#### Step 3. Make a small price list

bash

```
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csv
```

**You should see:** nothing printed; the folder now holds `prices.csv`.

#### Step 4. Write the program

Save this as `convert.php`:

php convert.php

```
<?php

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

use Gotenberg\Gotenberg;
use Gotenberg\Stream;

$address = 'http://localhost:3000';

$invoice = Gotenberg::chromium($address)
    ->pdf()
    ->outputFilename('invoice')
    ->html(Stream::string('index.html', '<h1>Invoice 1001</h1><p>Thank you for your order.</p>'));
Gotenberg::save($invoice, __DIR__);

$prices = Gotenberg::libreOffice($address)
    ->outputFilename('prices')
    ->convert(Stream::path(__DIR__ . '/prices.csv'));
Gotenberg::save($prices, __DIR__);

echo "Saved invoice.pdf and prices.pdf\n";
```

#### Step 5. Run it, then stop Marqius Kern

bash

```
php convert.php
docker stop kern
```

**You should see:**

text

```
Saved invoice.pdf and prices.pdf
kern
```

There are now two new files in the folder: `invoice.pdf`, with the heading Invoice 1001, and `prices.pdf`, with the price list.

### Version 3, for Gotenberg 9

**You need:** Docker, curl, PHP 8.3 or later and Composer.

**It takes:** about 5 minutes.

#### Step 1. Start Marqius Kern as Gotenberg 9

In a new, empty folder, start Marqius Kern with `KERN_GOTENBERG_VERSION=9.10.3` (`-e` gives the container this setting): it then reports 9.10.3 and answers a request that names neither version as Gotenberg 9 does. The second command waits until it answers.

bash

```
docker run --rm -d --name kern -p 3000:3000 -e KERN_GOTENBERG_VERSION=9.10.3 marqius/kern
curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/health
```

**You should see:** a long string of letters and digits (the container's ID), then a line that begins `{"status":"up"`.

#### Step 2. Install the client

This installs version 3.9.0 the same way, with Guzzle.

bash

```
composer require gotenberg/gotenberg-php:3.9.0 php-http/guzzle7-adapter:1.1.0
```

**You should see:** Composer list each package it installs, among them `- Installing gotenberg/gotenberg-php (v3.9.0): Extracting archive`.

#### Step 3. Make a small price list

bash

```
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > prices.csv
```

**You should see:** nothing printed; the folder now holds `prices.csv`.

#### Step 4. Write the program

The program is the same as for version 2. Save it as `convert.php`:

php convert.php

```
<?php

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

use Gotenberg\Gotenberg;
use Gotenberg\Stream;

$address = 'http://localhost:3000';

$invoice = Gotenberg::chromium($address)
    ->pdf()
    ->outputFilename('invoice')
    ->html(Stream::string('index.html', '<h1>Invoice 1001</h1><p>Thank you for your order.</p>'));
Gotenberg::save($invoice, __DIR__);

$prices = Gotenberg::libreOffice($address)
    ->outputFilename('prices')
    ->convert(Stream::path(__DIR__ . '/prices.csv'));
Gotenberg::save($prices, __DIR__);

echo "Saved invoice.pdf and prices.pdf\n";
```

#### Step 5. Run it, then stop Marqius Kern

bash

```
php convert.php
docker stop kern
```

**You should see:**

text

```
Saved invoice.pdf and prices.pdf
kern
```

There are now two new files in the folder: `invoice.pdf`, with the heading Invoice 1001, and `prices.pdf`, with the price list.

**If it does not work:**

-   **`docker run` says the name `kern` is already in use:** a container left from an earlier try still has it. Remove it with `docker rm -f kern`, then start again from step 1.
-   **`docker run` says port 3000 is already allocated or in use:** another server listens on it, often your old Gotenberg. Stop that first (`docker ps` lists the running containers).
-   **The `curl` command in step 1 gives up with an error:** `docker logs kern` shows Marqius Kern's messages.
-   **Composer stops because a PHP extension is missing** (it names it, beginning `ext-`): install that extension for your PHP, then run the command again. On Ubuntu, the packages `php-cli php-xml php-curl php-mbstring php-zip php-intl php-sqlite3 composer unzip git` give PHP everything the PHP examples in this guide use.

**What differs from Gotenberg:**

-   Version 2: its own tests check the requests it builds against a stand-in, not a server; two applications that print through it, solidtime (gotenberg-php 2.25) and InvoiceShelf (2.26), pass their PDF tests against Marqius Kern as against Gotenberg.
-   Version 3: every Gotenberg 9 operation is answered. What Marqius Kern does not do yet is answered 501, with the reason: on the LibreOffice route, `paperSize()`, `paperDimensions()`, `locale()` and `showTrackedChanges()`; on a signed PDF, the edits Gotenberg 9 adds to it as an update (rotating pages, setting metadata or bookmarks, attaching or removing files, autotagging; stamps are added as Gotenberg adds them, and the signatures stay); and remediation to PDF/A-4e.
-   Version 3: a text watermark (`nativeWatermarkText()`) is drawn on every page, but reading the page's text does not return its words, as it does from Gotenberg's PDF.

**What to check after switching:**

-   `Gotenberg::save()` names each file from the server's `Content-Disposition` header, which Marqius Kern sends as Gotenberg does: the names you set with `outputFilename()` stay;
-   with version 3, keep `KERN_GOTENBERG_VERSION=9.10.3` in the server's environment, and look in your logs for answers with status 501: each names one of the operations above.

* * *

## The Symfony bundle, in a new application.

The bundle calls the `base_uri` of its HTTP client, which its Flex recipe sets from `GOTENBERG_DSN` in `.env`; that setting stays as it is. Version 1.4.0 speaks Gotenberg 8's API.

**You need:** Docker, curl, PHP 8.2 or later and Composer.

**It takes:** about 10 minutes.

### Step 1. Start Marqius Kern

In a new, empty folder, start Marqius Kern and wait until it answers. The first command starts it in the background, as a container named `kern` on port 3000; the second asks its health check until it answers.

bash

```
docker run --rm -d --name kern -p 3000:3000 marqius/kern
curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/health
```

**You should see:** a long string of letters and digits (the container's ID), then a line that begins `{"status":"up"`.

### Step 2. Make a new Symfony application

This makes a new Symfony application in a folder named `invoices`, and goes into it.

bash

```
composer create-project "symfony/skeleton:7.4.*" invoices
cd invoices
```

**You should see:** Composer install Symfony, then end with Symfony's notes under `What's next?`, which this example does not need.

### Step 3. Add the bundle

The bundle's recipe (the set-up Symfony Flex runs when a package is added) is a community (contrib) recipe, so the first command allows those. The second adds Symfony's HTTP client and the bundle, version 1.4.0; the recipe writes `GOTENBERG_DSN=http://gotenberg:3000` in `.env`. If Composer asks whether to include the recipe's Docker configuration, either answer works here.

bash

```
composer config extra.symfony.allow-contrib true
composer require symfony/http-client sensiolabs/gotenberg-bundle:1.4.0
```

**You should see:** Composer install the bundle (`- Installing sensiolabs/gotenberg-bundle (v1.4.0): Extracting archive`), then the recipe's note `* Do not forget to start the new Gotenberg container if enabled.` Here, Marqius Kern from step 1 is that container.

### Step 4. Point the bundle at Marqius Kern

`.env.local` overrides `.env` on your machine. This one points the example at Marqius Kern on port 3000.

bash

```
echo 'GOTENBERG_DSN=http://localhost:3000' > .env.local
```

**You should see:** nothing printed.

### Step 5. Make a small price list

The price list goes in `assets/`, where the bundle looks for files, for the LibreOffice route.

bash

```
mkdir assets
printf 'Item,Qty,Price\nTea,2,3.50\nCoffee,1,4.20\n' > assets/prices.csv
```

**You should see:** nothing printed.

### Step 6. Write a console command

A console command that makes both PDFs. Save it as `src/Command/InvoiceCommand.php`:

php src/Command/InvoiceCommand.php

```
<?php

namespace App\Command;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;
use Sensiolabs\GotenbergBundle\Processor\FileProcessor;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Filesystem\Filesystem;

#[AsCommand(name: 'app:invoice', description: 'Makes invoice.pdf and prices.pdf')]
final class InvoiceCommand extends Command
{
    public function __construct(
        private readonly GotenbergPdfInterface $gotenberg,
        #[Autowire('%kernel.project_dir%')]
        private readonly string $projectDir,
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->gotenberg->html()
            ->contentRaw('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Invoice 1001</title></head><body><h1>Invoice 1001</h1><p>Thank you for your order.</p></body></html>')
            ->fileName('invoice')
            ->processor(new FileProcessor(new Filesystem(), $this->projectDir))
            ->generate()
            ->process();

        $this->gotenberg->office()
            ->files('prices.csv')
            ->fileName('prices')
            ->processor(new FileProcessor(new Filesystem(), $this->projectDir))
            ->generate()
            ->process();

        $output->writeln('Saved invoice.pdf and prices.pdf');

        return Command::SUCCESS;
    }
}
```

### Step 7. Run it, then stop Marqius Kern

bash

```
php bin/console app:invoice
docker stop kern
```

**You should see:**

text

```
Saved invoice.pdf and prices.pdf
kern
```

There are now two new files in the `invoices` folder: `invoice.pdf`, with the heading Invoice 1001, and `prices.pdf`, with the price list.

**If it does not work:**

-   **`docker run` says the name `kern` is already in use:** a container left from an earlier try still has it. Remove it with `docker rm -f kern`, then start again from step 1.
-   **`docker run` says port 3000 is already allocated or in use:** another server listens on it, often your old Gotenberg. Stop that first (`docker ps` lists the running containers).
-   **The `curl` command in step 1 gives up with an error:** `docker logs kern` shows Marqius Kern's messages.
-   **Composer stops because a PHP extension is missing** (it names it, beginning `ext-`): install that extension for your PHP, then run the command again. On Ubuntu, the packages `php-cli php-xml php-curl php-mbstring php-zip php-intl php-sqlite3 composer unzip git` give PHP everything the PHP examples in this guide use.

**What differs from Gotenberg:** The client tests use a stand-in for the server, so they do not establish server compatibility. Use the example above to check the integration in your environment.

**What to check after switching:**

-   if you let Flex add the recipe's Docker configuration, `compose.yaml` has a `gotenberg` service with the image `gotenberg/gotenberg:8`: that image line is the one to change ([the switching guide's Docker Compose section](https://marqius.com/gotenberg/guide#2-docker-compose)), and `GOTENBERG_DSN` stays;
-   a Twig template that uses `gotenberg_asset()` sends its pictures and style sheets with the page: convert one such document and compare it with `upgrade-check` ([the switching guide's first section](https://marqius.com/gotenberg/guide#1-before-you-switch)).

* * *

## laravel-pdf, in a new application.

With `LARAVEL_PDF_DRIVER=gotenberg`, laravel-pdf calls `GOTENBERG_URL` (the config key `laravel-pdf.gotenberg.url`); both stay as they are.

**You need:** Docker, curl, PHP 8.3 or later and Composer.

**It takes:** about 10 minutes.

### Step 1. Start Marqius Kern

In a new, empty folder, start Marqius Kern and wait until it answers. The first command starts it in the background, as a container named `kern` on port 3000; the second asks its health check until it answers.

bash

```
docker run --rm -d --name kern -p 3000:3000 marqius/kern
curl -sS --fail --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/health
```

**You should see:** a long string of letters and digits (the container's ID), then a line that begins `{"status":"up"`.

### Step 2. Make a new Laravel application

This makes a new Laravel application in a folder named `invoices`, and goes into it.

bash

```
composer create-project "laravel/laravel:^13.0" invoices
cd invoices
```

**You should see:** Composer install Laravel, then Laravel set the new application up, with lines such as `Application key set successfully.` and its first database tables marked `DONE`.

### Step 3. Add laravel-pdf

This adds laravel-pdf, version 2.14.0.

bash

```
composer require spatie/laravel-pdf:2.14.0
```

**You should see:** Composer install laravel-pdf, then Laravel list the packages it found, `spatie/laravel-pdf` among them, each marked `DONE`.

### Step 4. Point its Gotenberg driver at Marqius Kern

This adds two lines to `.env`: `LARAVEL_PDF_DRIVER=gotenberg` chooses laravel-pdf's Gotenberg driver, and `GOTENBERG_URL` gives Marqius Kern's address.

bash

```
printf '\nLARAVEL_PDF_DRIVER=gotenberg\nGOTENBERG_URL=http://localhost:3000\n' >> .env
```

**You should see:** nothing printed.

### Step 5. Write an Artisan command

An Artisan command that makes the invoice. Save it as `app/Console/Commands/PrintInvoice.php` (Laravel finds commands in this folder by itself):

php app/Console/Commands/PrintInvoice.php

```
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Spatie\LaravelPdf\Facades\Pdf;

class PrintInvoice extends Command
{
    protected $signature = 'invoice:print';

    protected $description = 'Makes invoice.pdf';

    public function handle(): void
    {
        Pdf::html('<h1>Invoice 1001</h1><p>Thank you for your order.</p>')
            ->format('a4')
            ->save(base_path('invoice.pdf'));

        $this->info('Saved invoice.pdf');
    }
}
```

### Step 6. Run it, then stop Marqius Kern

bash

```
php artisan invoice:print
docker stop kern
```

**You should see:**

text

```
Saved invoice.pdf
kern
```

There is now a new file in the `invoices` folder: `invoice.pdf`, with the heading Invoice 1001.

**If it does not work:**

-   **`docker run` says the name `kern` is already in use:** a container left from an earlier try still has it. Remove it with `docker rm -f kern`, then start again from step 1.
-   **`docker run` says port 3000 is already allocated or in use:** another server listens on it, often your old Gotenberg. Stop that first (`docker ps` lists the running containers).
-   **The `curl` command in step 1 gives up with an error:** `docker logs kern` shows Marqius Kern's messages.
-   **Composer stops because a PHP extension is missing** (it names it, beginning `ext-`): install that extension for your PHP, then run the command again. On Ubuntu, the packages `php-cli php-xml php-curl php-mbstring php-zip php-intl php-sqlite3 composer unzip git` give PHP everything the PHP examples in this guide use.

**What differs from Gotenberg:** No differences were reported in the library tests referenced below. Those results do not establish identical output for every document.

**What to check after switching:**

-   a view that waits with `waitUntilReady()` for a chart drawn by JavaScript: Marqius Kern runs scripts that build the page but has no canvas to draw on ([the switching guide's first section](https://marqius.com/gotenberg/guide#1-before-you-switch)), so convert that view first;
-   with `GOTENBERG_USERNAME` and `GOTENBERG_PASSWORD` set, start Marqius Kern as you started Gotenberg: `--api-enable-basic-auth` with the `GOTENBERG_API_BASIC_AUTH_USERNAME` and `GOTENBERG_API_BASIC_AUTH_PASSWORD` variables.

* * *

## Compatibility results

The public Marqius compatibility scoreboard reports these results for Marqius Kern 0.12.18, tested on 30 November 2026 and reviewed here on 2 December 2026. The counts cover the named libraries’ or applications’ assertions, not identical rendering of every customer PDF. Compare your own documents before switching.

| 
Library and version

 | 

Pass on Gotenberg

 | 

Pass on Marqius Kern

 |
| --- | --- | --- |
| 

spatie/laravel-pdf 2.14.0's own tests

 | 

14

 | 

14

 |

[See every test on the scoreboard](https://github.com/marqiushq/gotenberg-compatibility#the-results)

gotenberg-php and the Symfony bundle test against a stand-in for the server. Their own tests do not establish server compatibility; use the examples above to check your deployment. The application tests in the table cover only the assertions those applications make.

* * *

## Licensing Marqius Kern

**Personal, teaching and open-source use is free** with a Community licence, including open-source projects' CI runs and documentation builds.

1.  **Get your free key** on [the Marqius Kern licence page](https://marqius.com/licence/marqius-kern), then sign in with Google.
2.  Tick "I'll use Marqius Kern only for personal, teaching or open-source work".
3.  **Get my free key**, then **Copy key**.
4.  Set it as the variable `MARQIUS_LICENCE` on your server.

**Anything done by or for a business,** including internal tools and client work, needs a paid licence. [See the plans and prices](https://marqius.com/licence/marqius-kern).

* * *

## Deploy Marqius Kern on Railway

For a hosted PDF server, start with the [Marqius Kern deployment template on Railway](https://railway.com/deploy/marqius-kern). The examples in this guide run locally; when using Railway, configure your client with the service’s HTTPS address and the generated credentials shown in its Variables tab.

[Deploy Marqius Kern on Railway](https://railway.com/deploy/marqius-kern)

## Before you switch

Compare your own documents side by side first, as the switching guide shows, then switch.

[Read the switching guide](https://marqius.com/gotenberg/guide) · [Get your free key](https://marqius.com/licence/marqius-kern)

[Explore all nine Marqius Kern developer guides](https://marqius.com/gotenberg/developers/)

## Reader questions

### Does gotenberg-php work with Marqius Kern?

Yes, both versions: gotenberg-php 2, written for Gotenberg 8, and gotenberg-php 3, written for Gotenberg 9. Marqius Kern answers both APIs on one server.

### Does laravel-pdf's Gotenberg driver work with Marqius Kern?

Yes. laravel-pdf's own tests, the 14 that pass against Gotenberg, pass against Marqius Kern on the public scoreboard. Its Gotenberg address stays as it is.

### Does the Symfony GotenbergBundle work with Marqius Kern?

Yes. GOTENBERG\_DSN stays as it is; the switch is the image line of your compose file.

### How do I add my licence?

Personal, teaching and open-source use is free with a Community licence: get the key on [the Marqius Kern licence page](https://marqius.com/licence/marqius-kern) and set it as the variable MARQIUS\_LICENCE on the server. Without a key, Marqius Kern makes the same documents and says in its log that it has none. Anything done by or for a business needs a paid licence.

## Keep reading

[Marqius Kern guides for every client](https://marqius.com/gotenberg/developers/) [Use Marqius Kern with Ruby and Rails](https://marqius.com/blog/ruby-rails-gotenberg-marqius-kern/) [Generate PDFs in Swift with gotenberg-kit and Marqius Kern](https://marqius.com/blog/swift-gotenberg-kit-marqius-kern/) [Generate PDFs in Rust with gotenberg\_pdf and Marqius Kern](https://marqius.com/blog/rust-gotenberg-pdf-marqius-kern/) [All journal guides](https://marqius.com/blog/)

Source for this page [^official-page].

[^official-page]: https://marqius.com/blog/php-laravel-symfony-marqius-kern/

[Browse this section](index.md) · [Knowledge index](../index.md)
