Cookbook

Integrate phpxlsx with Slim

Warning

To run phpxlsx with Slim it is mandatory to use the package that supports namespaces. This package is available for Advanced and Premium licenses.

The installation of phpxlsx in a project that works with Composer can be manual or using a private repository with GitHub, Bitbucket or any other distributed version control system.

In order to use a private repository with GitHub or Bitbucket, you have to generate and use an SSH key:

To perform a manual integration just follow these easy steps:

  • 1- Copy the content of the phpxlsx package in the folder vendor/phpxlsx.
  • 2- Open the file composer.json. Add the autoload section, in case it doesn't exist yet. Then add the following classmap:
    "vendor/phpxlsx/Classes/Phpxlsx"
In a Slim clean installation, the section should look like this:

  • 3- Update the autoloader of Composer:

Now, with these three easy steps completed, you can work with phpxlsx.

As an example, let's create a XLSX in a controller, and then save it in the public folder with the name output.xlsx: