Download the PHP package whitedigital-eu/document-generator-bundle without Composer
On this page you can find all versions of the php package whitedigital-eu/document-generator-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whitedigital-eu/document-generator-bundle
More information about whitedigital-eu/document-generator-bundle
Files in whitedigital-eu/document-generator-bundle
Package document-generator-bundle
Short Description Document generator
License MIT
Informations about the package document-generator-bundle
Document Generator bundle
What is it?
Document Generator bundle is step based document generator library for projects using symfony and api-platform.
System Requirements
PHP 8.2+
Symfony 6.3+
Installation
The recommended way to install is via Composer:
After this, you need to update your database schema to use Document entity.
If using migrations:
If by schema update:
This will enable new Document
api resource with /api/documents
iri.
Components
- Task - requirement and config class that extends AbstractDocumentTask and defines most of the logical parts in document generator.
- 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 - Generator - class that produces a generated result (binary data of path to a file), from defined data, template and additional, optional context
- GeneratorContext - class that holds additional, optional context for generator to perform the document generation
- 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
- Define new
Task
that extendsAbstractDocumentTask
and define required functions:
__construct
AbstractDocumentTask requires 3 services:
- EntityManagerInterface
- Generator - TwigToPdfGenerator from library or other defined one
- Transformer - service defined by you (more about it below)
getTransformerFields
getTemplatePath
getType
getInputType
- Define new Transformer that implements TransformerInterface:
transformer can return none, some or all of the fields listed in getTransformedFields an array of fields
- Use generation Defined task can now be used as a service
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
If for any reason you need to regenerate existing document, you can use built-in DocumentTask with existing document entity.
All versions of document-generator-bundle with dependencies
api-platform/core Version ^3.2
doctrine/dbal Version *
doctrine/orm Version *
gotenberg/gotenberg-php Version *
symfony/config Version *
symfony/dependency-injection Version *
symfony/http-kernel Version *
symfony/serializer Version *
symfony/service-contracts Version *
twig/twig Version ^3.8
vich/uploader-bundle Version *
whitedigital-eu/entity-resource-mapper-bundle Version ^0.24
whitedigital-eu/storage-item-resource Version ^0.3