umanit / document-generator-bundle
This bundle is used to drive the document generator microservice developed by UmanIT: https://github.com/umanit/microservice-document-generator
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1
- ext-json: *
- ext-openssl: *
- php-http/discovery: ^1.7
- php-http/httplug: ^2.0
- php-http/message-factory: ^1.0
- psr/http-message: ^1.0
- symfony/options-resolver: ^4.4|^5.0
Provides
README
This bundle is used to drive the document generator microservice developed by UmanIT: https://github.com/umanit/microservice-document-generator
Installation
$ composer require umanit/document-generator-bundle
The bundle relies on HTTPlug to perform HTTP requests, so you will need to install a client implementation to use it. For example, the following will use the HTTPlug message factory and the Guzzle adapter.
$ composer require php-http/message php-http/guzzle6-adapter
Configuration
umanit_document_generator.base_uri
: Base URI of the API used to generate documents.umanit_document_generator.encryption_key
: (Optional) Key used to crypt message before calling the API. It must match the one defined in the micro-service.
Usage
The only exposed service is umanit_document_generator.document_generator
. It provides all the necessary methods to
communicate with the micro-service API.
You can generate PNG or PDF using an URL or a HTML source code string.
Examples:
<?php $generator = $container->get('umanit_document_generator.document_generator'); // Get a PNG of https://www.google.fr $image = $generator->generatePngFromUrl('https://www.google.fr'); // Get a PDF from a HTML code source $pdf = $generator->generatePdfFromHtml('<html><body>Hello World!</body></html>');
Each methods provides an additional parameter to specify other supported options by the micro-service,
such as decode
for HTML generation or pageOptions
and scenario
for both types.
Data encryption
By default, messages are not encrypted before calling the API. If you want to enable this feature, ensure you have
define the umanit_document_generator.encryption_key
configuration the same as in the micro-service then call the
encryptData(true)
method on the service. The encryption could be disabled the same way by calling
encryptData(false)
.