Hello,
As the trial package only includes the Basic features, using phpdocx 8 you can generate the TOCs as a WordFragment and replace an existing placeholder in the template by the TOC using replaceVariableByWordFragment (https://www.phpdocx.com/api-documentation/templates/replace-variable-word-fragment-Word-document).
Although we recommend using DOCXPath (Advanced and Premium licenses).
Regards.