2

I'm trying to implement PhpPresentation to convert some files, so I have the following code:

use PhpOffice\PhpPresentation\src\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\src\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\src\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\src\PhpPresentation\Style\Alignment;

For some reason exactly this piece of code is causing 500 Internal server error. I have error reporting set to all, but no errors are shown. The path is right, i have the PhpOffice folder in my root directory(public_html) and the corresponding subfolders too.

autoloader code is loaded this way:

require_once 'PhpOffice/PhpPresentation/src/PhpPresentation/Autoloader.php';
  \PhpOffice\PhpPresentation\Autoloader::register();
  require_once 'PhpOffice/src/Common/Autoloader.php';
  \PhpOffice\Common\Autoloader::register();
  • Take a look into your http servers error log file, that is where you can read what the actual issue is. – arkascha May 02 '17 at 09:49
  • Most likely those definitions cannot be found by your auto loader. – arkascha May 02 '17 at 09:49
  • `syntax error, unexpected 'use'` on the first use line. Here is my full function https://codeshare.io/aYAdzL –  May 02 '17 at 09:57
  • a few ideas: are there any lines before the `use` lines? maybe one with a missing `;`? and just to be sure...what is your PHP version? – cypherabe May 02 '17 at 10:04
  • 1
    Ok, that means most likely your php version is outdated and below `5.6`. You want to upgrade. – arkascha May 02 '17 at 10:07
  • I'm not missing a semicolumn and my PHP version is 5.6. The full error is `syntax error, unexpected 'use' (T_USE)` –  May 02 '17 at 10:12

1 Answers1

3

Issue fixed, thanks to this https://stackoverflow.com/a/33355711/7926703

I was using 'use' inside a function which is wrong and error-causing.

Community
  • 1
  • 1