In-memory DOCX documents
phpdocx Premium licenses include support for in-memory documents. Thanks to this functionality it is possible to work without files in the fs. Instead, you can use in memory objects or from other sources like databases, in-memory data structures, redis… This also enables better performance and flexibility of use.
DOCXStructure is the class that serves as an in-memory DOCX in phpdocx. An object of that class can be generated on the fly with CreateDocx and the static attribute $returnDocxStructure:
Or from an existing file, using the DOCXStructure class:
Or from any valid stream with the DOCXStructureFromStream class, e.g. an URL:
DOCXStructure can be easily serialized: Serializing templates for later reuse. For example, as a template to generate new documents:
The classes and methods that support in-memory DOCX are the following:
There are many examples available in the directory 'examples' of the Premium package to illustrate its use.
DOCXStructure objects should not be confused with the phpdocx stream mode. The latter generates and returns automatically the DOCX file, but it doesn't allow storing it unless its output is captured. That's why it is useful for specific purporses as generating and downloading DOCX without being neccesary its later reuse.