Forum


Replies: 2   Views: 3148
Using phpdocx with yii framework
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by mf@netelite.ch  · 06-06-2011 - 23:58

Hello

I'm trying to use phpdocx with Yii. The code snippet below (table example) is in a 'view' file of yii and it works.
BUT the following code with (template example) leads to the following Fatal error:

[b]Fatal error: Call to a member function close() on a non-object in /var/www/JobCockpit/phpdocx/classes/CreateTemplate.inc on line 163[/b]

How could this be resolved?

[i](template example) - error
[/i]
[code]
define('PHPDOCX_INCLUDE_PATH', (dirname(Yii::app()->basePath)).'/phpdocx');
require_once PHPDOCX_INCLUDE_PATH.'/classes/AutoLoader.inc';
spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('AutoLoader','load'));

$docx = new CreateDocx();
$docx->addTemplate('files/mytemplate.docx');
$docx->addTemplateVariable('FIELD1', $model->field1);
$docx->addTemplateVariable('FIELD1', $model->field2);

$filename = "phpdocxGeneratedFile";
$docx->createDocx($filename);[/code]


[i]
(table example) - works[/i]

[code]define('PHPDOCX_INCLUDE_PATH', (dirname(Yii::app()->basePath)).'/phpdocx');
require_once PHPDOCX_INCLUDE_PATH.'/classes/AutoLoader.inc';
spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('AutoLoader','load'));


$docx = new CreateDocx();

$myvar = $model->field1;
$valuesTable = array(
array(
$myvar,
12
),
array(
21,
22
),
);

$paramsTable = array(
'border' => 'single',
'border_sz' => 20
);

$docx->addTable($valuesTable, $paramsTable);
$filename = "phpdocxGeneratedFile";
$docx->createDocx($filename);[/code]



Posted by admin  · 11-04-2013 - 12:12

Hi,

Please try template example isolate from Yii. Seems there're some wrong permissions; also activate LOG debug to get more info.

Regards.