This is really annoying.. so I tried the following:
public function debug(Request $request) { \Phpdocx\Create\CreateDocx::$returnDocxStructure = true; $queue = array(); $docx = new \Phpdocx\Create\CreateDocxFromTemplate('/path_to_docx'); $queue[] = $docx->createDocx(); \Phpdocx\Create\CreateDocx::$returnDocxStructure = false; \Phpdocx\Create\CreateDocx::$streamMode = true; $merge = new \Phpdocx\Utilities\MultiMerge(); $merge->mergeDocx($queue[0], array(), 'example.docx', array()); }
This still gives me the abovementioned issue. I don't think it gets simpler than this.
If I alter the sample2.php a bit to include two times CreateDocxFromTemplate of our template and include streammode = true after Phpdocx\Create\CreateDocx::$returnDocxStructure = false; it works fine.
Could it be something of Phpdocx (namespace version) in combination with Laravel?