Forum


Replies: 3   Views: 3957
Php fatal error: uncaught error: call to undefined method phpdocx\\create\\createdocx::replacevaria
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 PKF_tech  · 19-01-2018 - 13:05

Hi,

I have the enterprise version, things working OK until I tried to add replaceVariableByHTML gte this error in server logs, any ideas?

 

PHP Fatal error:  Uncaught Error: Call to undefined method Phpdocx\\Create\\CreateDocx::replaceVariableByHTML()

Tony

Posted by PKF_tech  · 19-01-2018 - 14:38

Thanks, although these instructions don't match the version I downloaded, all the classes are stored in various folders, starting:

\Classes\Phpdocx\

with CreateDocx in:

\Classes\Phpdocx\Create

so to get working I added: 
require_once 'Classes/Phpdocx/Create/CreateDocx.inc';

but no other functions work, unless I create further includes:
require_once 'Classes/Phpdocx/Elements/WordFragment.inc';

So any ideas on how to resolve this please?

Posted by admin  · 19-01-2018 - 15:01

Hello,

We recommend you to check the included samples in your package and the practical guide explains how to use both packages (classic and namespaces). For example on https://www.phpdocx.com/documentation/practical/working-with-templates you can read about how to use the included autoloader or you can integrate it with Composer (https://www.phpdocx.com/documentation/cookbook/integrate-phpdocx-with-composer).

For example, the included sample Core\addText\sample_3.php that use CreateDocx and WordFragment:

<?php

require_once '../../../Classes/Phpdocx/Create/CreateDocx.inc';

$docx = new Phpdocx\Create\CreateDocx();

//create a Word fragment with an image
$image = new Phpdocx\Elements\WordFragment($docx);
$imageOptions = array(
    'src' => '../../img/image.png',
    'scaling' => 50, 
    'float' => 'right',
    'textWrap' => 1 
    );
$image->addImage($imageOptions);

The library includes various folders because each folder is a PHP namespace (this is how PHP namespaces work). If you don't want to use PHP namespaces, you can download and use the classic package on MY PHPDOCX page after login.

Regards.