0

I'm trying to use PHPPowerpoint and his examples

But I get the following error :

*Sample 01 Complex
14:56:03 Create new PHPPresentation object
14:56:03 Set properties
14:56:03 Remove first slide
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create a shape (rich text)
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create a shape (rich text)
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create a shape (rich text)

**Fatal error: Class 'Common\XMLWriter' not found in .....\test phppowerpoint\PHPPowerPoint-develop\src\PhpPresentation\Writer\PowerPoint2007\AbstractPart.php on line 76***

Can anyone help me to fix this error ? Thank you

Matt Habel
  • 1,493
  • 2
  • 14
  • 35
Yann L
  • 11
  • 2
  • I have the same issue, I am not able to understand the directory structure and where to place the common-develop folder? – Incredible Oct 28 '15 at 13:15

2 Answers2

4

You are facing this problem because common office php files are missing. Download:

https://github.com/PHPOffice/Common

and include it in your source code (after updating the path):

require_once 'Common-develop/src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
Raj
  • 41
  • 2
  • Can you explain where actually I do have to place these common files in directory? As, there is no folder like PhpOffice – Incredible Oct 28 '15 at 12:12
  • Can you please tell me where do i need to store these Common library files? – void Jan 14 '16 at 08:36
1

As Raj said, you need to download the common PHPOffice classes from the link he specified. You can place them where is more convenient to you. In my case, I placed the Common folder inside the src folder (so in src you'd have PHPPresentation and Common). Afterwards, you need to include them in the source code, as Raj said

require_once 'PHPPresentation/src/Common/Autoloader.php;
\PhpOffice\Common\Autoloader::register();

You'll have to update the path in require_once to your actual path.

P.S.: Don't forget about writing permissions on the destination folder, otherwise the library won't be able to write out the presentation file!

Sebastianb
  • 2,020
  • 22
  • 31