0

I am developing a Laravel web application that uses the library PHPSpreadsheet. It creates a new workbook and then generates a graph inside the workbook. This is my code.

use PhpOffice\PhpSpreadsheet\Spreadsheet;  

class MakeCertificates 
{
    public static function createReport($id)
    {
        // Setup
        //intiate workbook
        $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
    ...

My code works on localhost xampp however I have deployed it to a web server and receive the following error.

include(/home/machgr5/sis.machgroup.co.uk/vendor/composer/../phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php): failed to open stream: No such file or directory

I get this error at this line:

$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

Does anyone know why this is happening?

Curtis Thompson
  • 63
  • 1
  • 2
  • 10

1 Answers1

0

This can happen for a few reasons. The things I can immediatly tell:

This is correct

use PhpOffice\PhpSpreadsheet\Spreadsheet; 

But instantiate without the full namespace in your method:

$spreadsheet = new Spreadsheet();

Next the autoloader is telling you he can't find the location of your PHPSpreadsheet class. Did you install it on your server? (Run composer install)

Maybe run composer dumpautoload -o as well, which will rebuild the class map for you.

AMM
  • 103
  • 3
Analogue
  • 87
  • 5