mikemix / dompdfmodule
DOMPDF Zend Framework lightweight module
Installs: 11 623
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 1
Requires
- php: ^5.5 || ^7.0
- dompdf/dompdf: ^0.7.0
- zendframework/zend-servicemanager: ^2.0 || ^3.0
Suggests
- mikemix/mxdi-module: Configure dependency injection with annotations
This package is not auto-updated.
Last update: 2020-05-10 21:20:54 UTC
README
DOMPDF library wrapper as lightweight ZF2/ZF3 module.
Requirements
Installation
Installation of DOMPDFModule uses PHP Composer. For more information about PHP Composer, please visit the official PHP Composer site.
Installation steps
-
cd my/project/directory
-
create a
composer.json
file with following contents:{ "require": { "mikemix/dompdfmodule": "^3.0" } }
-
install PHP Composer via
curl -s http://getcomposer.org/installer | php
(on windows, download http://getcomposer.org/installer and execute it with PHP) -
run
php composer.phar install
-
open
my/project/directory/config/application.config.php
and add the following key to yourmodules
:'dompdfmodule',
Configuration options
You can override default options via the dompdf
key in your local or global config files. See the dompdfmoule\Service\dompdfFactory.php file for the list of default settings.
Full list of possible settings is available at the official DOMPDF library site.
Example usage
Side note: use of
getServiceLocator()
in the controller is deprecated since in ZF3. Make sure you create your controller via a factory and inject the Dompdf object in the constructor.
<?php // some controller public function indexAction() { /** @var \Dompdf\Dompdf $dompdf */ $dompdf = $this->getServiceLocator()->get('dompdf'); $dompdf->load_html('<strong>Ehlo World</strong>'); $dompdf->render(); file_put_contents(__DIR__ . '/document.pdf', $dompdf->output()); }