Hello,
You can add more than one content to the same WordFragment:
$footerWordFragment = new WordFragment($docx, 'defaultFooter');
$optionsLeft = array(
'textAlign' => 'left',
);
$footerWordFragment->addText('Footer text', $optionsLeft);
$optionsRight = array(
'textAlign' => 'right',
);
$footerWordFragment->addPageNumber('numerical', $optionsRight);
$docx->addFooter(array('default' => $footerWordFragment));
But to accomplish your task and get a correct vertical alignment for both contents (and more if needed), we recommend you to use a table:
$footerWordFragmentText = new WordFragment($docx, 'defaultFooter');
$optionsLeft = array(
'textAlign' => 'left'
);
$footerWordFragmentText->addText('Footer text', $optionsLeft);
$footerWordFragmentPageNumber = new WordFragment($docx, 'defaultFooter');
$optionsRight = array(
'textAlign' => 'right'
);
$footerWordFragmentPageNumber->addPageNumber('numerical', $optionsRight);
$valuesTable = array(
array(
$footerWordFragmentText,
$footerWordFragmentPageNumber,
),
);
$paramsTable = array(
'tableStyle' => 'LightListAccent1PHPDOCX',
'tableAlign' => 'center',
'columnWidths' => array(3000, 3000),
);
$footerWordFragmentTable = new WordFragment($docx, 'defaultFooter');
$footerWordFragmentTable->addTable($valuesTable, $paramsTable);
$docx->addFooter(array('default' => $footerWordFragmentTable));
Or you can use a custom template (https://www.phpdocx.com/documentation/practical/headers-and-footers) or import headers and footers from an external DOCX (https://www.phpdocx.com/api-documentation/layout-and-general/import-headers-and-footers-Word-document-with-PHP).
Regards.