Replies: 3   Views: 3357
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


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()


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:


with CreateDocx in:


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

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

So any ideas on how to resolve this please?

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


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 you can read about how to use the included autoloader or you can integrate it with Composer (

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


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

$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 

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.