The DOMPDF module integrates the DOMPDF library with Zend Framework 2 with minimal effort on the consumer's end.
Installation of DOMPDFModule uses PHP Composer. For more information about PHP Composer, please visit the official PHP Composer site.
-
cd my/project/directory
-
create a
composer.json
file with following contents:{ "require": { "dino/DOMPDFModule": "dev-master" } }
-
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',
Copy dino/DOMPDFModule/config/module.dompdf.local.php
to my/project/directory/config/autoload/module.dompdf.local.php
and reference dino/DOMPDFModule/config/module.config.php
for configration options that you can override.
<?php
namespace Application\Controller;
use Zend\Mvc\Controller\ActionController;
use DOMPDFModule\View\Model\PdfModel;
class ReportController extends ActionController
{
public function monthlyReportPdfAction()
{
return new PdfModel(
array(), // Variable assignments per Zend\View\Model\ViewModel
array(
'fileName' => 'monthly-report', // Optional; triggers PDF download, automatically appends ".pdf"
'paperSize' => 'a4',
'paperOrientation' => 'landscape'
)
);
}
}
- Create tests
- Add support for DOMPDF CLI