I am currently following the example here https://www.phpdocx.com/api-documentation/templates/replace-variable-text-Word-document, but the example is a bit confusing.
require_once 'classes/CreateDocx.php';
$docx = new CreateDocxFromTemplate('document.docx');
$first = 'PHPDocX';
$multiline = 'This is the first line.\nThis is the second line of text.';
$variables = array('FIRSTTEXT' => $first, 'MULTILINETEXT' => $multiline);
$options = array('parseLineBreaks' =>true);
$docx->replaceVariableByText($variables, $options);
$docx->createDocx('output');
1. As you can see the example above, it is using the CreateDocxFromTemplate class but then the imported class was CreateDocx.php.