Cookbook

Integrate phpxlsx with Zend Framework 2

Warning

To run phpxlsx 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 phpxlsx package and paste it in the directory vendor/phpxlsx.
  • 2- Open the file composer.json and add the following classmap in the autoload section:
    "vendor/phpxlsx/Classes/Phpxlsx"
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 phpxlsx. As a practical example, let's create a XLSX in a controller and save it in the public directory with the name output.xlsx: