I am going to answer this question: "What's the Anatomy of a DocX File?"
Official Answer
Please see the official OOXML article, "Anatomy of OOXML," for an example DocX directory structure :
http://officeopenxml.com/anatomyofOOXML.php
For an example DocX XML document :
http://officeopenxml.com/WPsampleDoc.php
What I Personally Suggest
HOWEVER, after following these meticulously, and guessing where the details got foggy, I was unable to make the .docx
file.
I chose this short cut : Make a Docx
file in Libre Office (supports .docx
extensions), make a generic template in the format of the docx files you expect to be generating, save the file as .docx, copy and save as .zip.
Open this .zip directory, and what you'll see I found to be much better at explaining the spec than the above, official links.
Example
For example, if you're making articles in .docx, you'd have [[Title]]
at the top in title-casing/formatting, By: [[Author]]
, for author, etc., etc.. Then with your code, use that template, and just swap out the [[field]]
for whatever $data
you're ready to put into it.