Hello,
The problem is that you are not adding the defaultFooter scope in the WordFragment and you need to use the main CreateDocx, not other WordFragment:
$footer = new WordFragment($toc, 'defaultFooter');
$footerImage = new WordFragment($toc, 'defaultFooter');
$footerImage->addImage($imageOptions);
$pageNumber = new WordFragment($toc, 'defaultFooter');
$pageNumber->addPageNumber('numerical');
$divider = new WordFragment($toc, 'defaultFooter');
$divider->addText(' | ');
On https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml and the included samples you can read more information about WordFragment scopes.
Regards.