Cookbook

Integrate phppptx with Yii 2

Warning

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

The installation of phppptx 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.

To use a private repository with GitHub, Bitbucket or Gitlab you have to generate and use an SSH key or auth.json:

Advanced and Premium licenses include a sample composer.json file (plugins/sample_composer.json file in the namespaces package) that can be added in a phppptx private repository.

To perform a manual integration just follow these three easy steps:

  • 1- Copy the content of the phppptx package in the folder you use for third parties libraries, e.g. lib/phppptx, vendor/phppptx or 3rd-party/phppptx.
  • 2- Open the file composer.json and add the following classmap in the autoload section: "lib/phppptx/Classes/Phppptx" . Replacing lib/phppptx with the folder name where phppptx has been copied.
In a Yii 2 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 phppptx.

As an example, let's create a PPTX in a controller, and then save it in the webroot folder with the name output.pptx: