Integrate phpdocx with Zend Framework 2


To run phpdocx with Zend Framework 2 it is mandatory to use the package that supports namespaces. This package is available for Advanced and Premium licenses.

  • 1- Copy the content of the phpdocx package and paste it in the directory vendor/phpdocx.
  • 2- Open the file composer.json and add the following classmap in the autoload section:
In a clean installation of Zend Framework 2, this section should look like this:

  • 3- Update the autoloader of Composer:

With these three easy steps you are ready to work with phpdocx. As a practical example, let’s create a document in a controller and save it in the public directory with the name output.docx: