I did everything in the example mentioned in the doc. Only line that was changed was :
$docx = new CreateDocxFromTemplate("template.docx");
<?php
require_once 'path/to/phpdocx/phpdocx-corporate-5.5/classes/CreateDocx.inc';
$docx = new CreateDocxFromTemplate("template.docx");
$docx->addText('Table of Contents', array('bold' => true, 'fontSize' => 14));
$legend = array('text' => 'Click here to update the TOC',
'color' => 'B70000',
'bold' => true,
'fontSize' => 12);
$docx->addTableContents(array('autoUpdate' => true), $legend);
//we add now some headings so tehy show up in the TOC
$docx->addText('Chapter 1', array('pStyle' => 'Heading1PHPDOCX'));
$docx->addText('Section', array('pStyle' => 'Heading2PHPDOCX'));
$docx->addText('Another TOC entry', array('pStyle' => 'Heading3PHPDOCX'));
$docx->createDocx('example_addTableContents_1');
?>
And the Table of Contents did not get generated. Only the text as it is.