0

I need to add a footer to the first page of my document:

    require_once 'vendor\autoload.php';
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->addSection(array(
        'orientation' => 'portrait')
     );
    $footer = $section->addFooter(Footer::FIRST); <- Line 49

but I get an error:

Uncaught Error: Class 'Footer' not found in C:\xxxxxxxxxx:49

I've even tried requiring Footer.php in the package. Word document generation works fine without the Footer::FIRST parameter though I get the footer on every page. I also just upgraded to version 0.17 Any ideas why the error is occurring?

Lucas Meine
  • 1,524
  • 4
  • 23
  • 32
curtisnt
  • 13
  • 1

1 Answers1

3

Without the full namespace, PHP won't be able to find the right Footer class. To solve this, simply declare the full namespace of footer class

$footer = $section->addFooter(\PhpOffice\PhpWord\Element\Footer::FIRST);
Ermenegildo
  • 1,286
  • 1
  • 12
  • 19