Hello,
UPDATE: phpdocx 14 includes addHeaderSection and addFooterSection to accomplish this task. https://www.phpdocx.com/documentation/cookbook/headers-and-footers-for-sections
Are you generating the sections from scratch using phpdocx? Or do you need to add headers or footers to existing sections in a template?
If you are creating a DOCX with a single section using phpdocx you can use addHeader/addFotter methods setting default, even and first as array keys to insert each header/footer target of that section.
If you are creating a DOCX with multiple sections with their own headers and footers, then you need to use mergeDocx. Please check the documentation available on https://www.phpdocx.com/documentation/cookbook/headers-and-footers-for-sections.
There's no method to add new headers or footers to sections in existing documents. Using the importHeadersAndFooters method you can overwrite headers and footers of all sections importing the headers and footers from an external document. If you want to modify headers and footers from a template, they must exist in the template, so they can be changed using template methods or DOCXPath; there's no method to generate and add a header or footer to a section in a template.
Regards.