Hello,
The next version of phpdocx will allow returning a in-memory DOCX when using mergeDocx. phpdocx 9.0 doesn't include support.
Users with an active LUS (https://www.phpdocx.com/updates) can download beta releases and features not yet available in the stable package. If you purchase the LUS to your license (on MY PHPDOCX page after login) you can write to contact[at]phpdocx.com and the dev team will send you the new class that include support for returning in-memory DOCX in mergeDocx and a sample that illustrates how to use it.
Regards.