PHPackages                             whitedigital-eu/document-generator-bundle - 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. whitedigital-eu/document-generator-bundle

ActiveSymfony-bundle[PDF &amp; Document Generation](/categories/documents)

whitedigital-eu/document-generator-bundle
=========================================

Document generator

0.3.3(1y ago)0298↓100%1MITPHPPHP &gt;=8.2.0

Since Mar 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/whitedigital-eu/document-generator-bundle)[ Packagist](https://packagist.org/packages/whitedigital-eu/document-generator-bundle)[ RSS](/packages/whitedigital-eu-document-generator-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (16)Versions (13)Used By (0)

Document Generator bundle
-------------------------

[](#document-generator-bundle)

### What is it?

[](#what-is-it)

Document Generator bundle is step based document generator library for projects using symfony and api-platform.

### System Requirements

[](#system-requirements)

PHP 8.2+
Symfony 6.3+

### Installation

[](#installation)

The recommended way to install is via Composer:

```
composer require whitedigital-eu/document-generator-bundle
```

After this, you need to update your database schema to use Document entity.
If using migrations:

```
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
```

If by schema update:

```
bin/console doctrine:schema:update --force
```

This will enable new `Document` api resource with `/api/documents` iri.

### Components

[](#components)

1. Task - requirement and config class that extends AbstractDocumentTask and defines most of the logical parts in document generator.
2. Transformer - class that transforms input data into structure defined in your defined task.
    For now, package only comes with transformer that turns twig into pdf but this can be changed within project by creating your own transformers by implementing TransformerInterface
3. Generator - class that produces a generated result (binary data of path to a file), from defined data, template and additional, optional context
4. GeneratorContext - class that holds additional, optional context for generator to perform the document generation
5. Html to Pdf service - reusable service to generate pdf files from html. Here used within transformer but can be used elsewhere. Uses gotenberg in background.

### Usage

[](#usage)

1. Define new `Task` that extends `AbstractDocumentTask`

```
use Doctrine\ORM\EntityManagerInterface;
use WhiteDigital\DocumentGeneratorBundle\Generator\TwigToPdfGenerator;
use WhiteDigital\DocumentGeneratorBundle\Task\AbstractDocumentTask;

class TestDocumentTask extends AbstractDocumentTask
{

}
```

and define required functions:
\_\_construct

```
public function __construct(
     EntityManagerInterface $em,
     TwigToPdfGenerator $twigToPdfGenerator,
     ReceiptTransformer $receiptTransformer,
 ) {
     parent::__construct($em, $twigToPdfGenerator, $receiptTransformer);
 }
```

AbstractDocumentTask requires 3 services:

1. EntityManagerInterface
2. Generator - TwigToPdfGenerator from library or other defined one
3. Transformer - service defined by you (more about it below)

getTransformerFields

```
public function getTransformerFields(): array
{
    return [
        'field1' => 'string',
        'array1' => [
            'array2' => [
                'field2' => 'bool',
            ],
        ],
    ]; // array of fields that Transformer can contain
}
```

getTemplatePath

```
public function getTemplatePath(): string
{
    return '/path/to/defined/template.html.twig'; // must be in directory visible by twig, usually /templates
}
```

getType

```
public function getType(): string
{
    return 'TEST'; // simple identifier to separate different documents
}
```

getInputType

```
public function getInputType(): string
{
    return 'array'; // what type of data does Transformer require as input
}
```

2. Define new Transformer that implements TransformerInterface:

```
class TestTransformer implements Transformer
{
    public function getTransformedFields(mixed $input): array {
        return [
            'field1' => 'abc',
             'array1' => [
                'array2' => [
                    'field2' => false,
                ],
            ],
            'field3' => 3
        ];
    }
}
```

transformer can return none, some or all of the fields listed in getTransformedFields an array of fields

3. Use generation Defined task can now be used as a service

```
public function __construct(private TestDocumentTask $task)
{
}

public function abc()
{
    return $this->task->generate([1, 2, 3]);
}
```

Input of generate function must be type defined in Transformer.
generate function will return already Document entity or throw an error if something is wrong.

### Regenerate

[](#regenerate)

If for any reason you need to regenerate existing document, you can use built-in DocumentTask with existing document entity.

```
use WhiteDigital\DocumentGeneratorBundle\Entity\Document;use WhiteDigital\DocumentGeneratorBundle\Task\DocumentTask;
use Doctrine\ORM\EntityManagerInterface;

public function __construct(private DocumentTask $task, private EntityManagerInterface $em)
{
}

public function abc()
{
    return $this->task->generate($this->em->getRepository(Document::class)->find(123));
}
```

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance44

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 74.3% 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 ~16 days

Recently: every ~26 days

Total

8

Last Release

652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4db85e32518c5a6caa2fd625032a2b016ef42d60cf8a101c165cc5c0048b221?d=identicon)[k0d3r1s](/maintainers/k0d3r1s)

---

Top Contributors

[![k0d3r1s](https://avatars.githubusercontent.com/u/38725938?v=4)](https://github.com/k0d3r1s "k0d3r1s (26 commits)")[![acirulis](https://avatars.githubusercontent.com/u/27766961?v=4)](https://github.com/acirulis "acirulis (5 commits)")[![raraworks](https://avatars.githubusercontent.com/u/18421085?v=4)](https://github.com/raraworks "raraworks (4 commits)")

---

Tags

phpsymfonygeneratordocumentSymfony Bundledocument generator

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/whitedigital-eu-document-generator-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/whitedigital-eu-document-generator-bundle/health.svg)](https://phpackages.com/packages/whitedigital-eu-document-generator-bundle)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M647](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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