I'm trying to wrap my head around zend framework 2 and it's module system. I have the the skeleton application in the Getting Started guide working. I now want to use ZendPdf to load in an existing pdf file and work with it. I've done the following so far:
- downloaded and installed ZendPdf using composer to my skeleton app
- Added ZendPdf to my application_config.php
- Added a simple controller action to create a new ZendPdf class and load in a document
- I also created a view for the controller action.
When ever I call the action in the controller I get the following error
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZendPdf) could not be initialized
Obviously, from the error, I need to add zendpdf to the module_config.php so the ModuleManager can pick it up. This is were I get lost. I don't know how to configure zendpdf in the config file. This is what I have so far:
module.config in the Album Module
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
),
// Routes for
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
'zendpdf' => array() /* what to do here */
);
This is the controller action in my AlbumController
public function viewPdfAction()
{
$pdf = ZendPdf::load('/tmp/pdf_report.pdf');
}
This is the application.config
<?php
return array(
'modules' => array(
'Application',
'Album',
'AlbumRest',
'ZendPdf'
),
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
'./module',
'./vendor',
),
),
);
I've been reading the docs but am just not getting it. I need a push in the right direction.