Hello,
The first tip to improve the performance is to disable the autorepair option.
This is the signature of the constructor of CreateDocxFromTemplate.inc:
/**
* Construct
* @param string $docxTemplatePath path to the template we wish to use
* @param array $options
* The available keys and values are:
* 'preprocessed' (boolean) if true the variables will not be 'repaired'. Default value is false
* @access public
*/
public function __construct($docxTemplatePath, $options = array())
{
By default phpdocx repairs the placeholders (sometimes Word breaks the XML content adding nonneeded tags in the strings), so to get the best performance you need to disable it:
$docx = new CreateDocxFromTemplate('template.docx', array('preprocessed' => true));
The second tip is to split the DOCX in two or more documents. Instead of working with a single document, please separate it, for example in two or three DOCX, and in your code replace the document placeholders and then use the MultiMerge class to merge them.
We also advise you to check PHP config (APC is highly recommended) and the server specs.
Regards.