Hello,
You need to enable keepLines and keepNext options:
$docx->addText('Text content', array('keepLines' => true, 'keepNext' => true));
Please note that these options move the content to the same page of the next content, so this text will be moved if the whole table is in the next page. You can also use the addHeading method that applies those styles automatically.
If you want to keep a content and a whole table in the same page even if only some rows are not in the same page, please check the documentation available on https://www.phpdocx.com/documentation/snippets/prevent-page-break-table-add-table (you need to apply keepNext and keepLines in all paragraphs of the table).
Regards.