Hello,
Maybe you didn't set the correct heading levels that must appear in the TOC? On this page you can find more information about TOCs:
https://www.phpdocx.com/documentation/cookbook/tables-of-contents
This is a simple script that generate a DOCX from scratch adding a TOC and two headings (note the displayLevels option):
<?php
require_once 'classes/CreateDocx.inc';
$docx = new CreateDocx();
$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, 'displayLevels' => '1-3'), $legend);
$html = '<h1>Heading 1</h1>';
$html .= '<p>Other text</p>';
$html .= '<h2>Heading 2</h2>';
$docx->embedHTML($html);
$docx->createDocx('output');
If you open the DOCX with MS Word or LibreOffice and then update the TOC, both heading appear in the TOC.
Regards.