Answer the question
In order to leave comments, you need to log in
How to connect PhpWord (Class 'PHPWord' not found)?
Downloaded PhpWord via composer:
D:\xampp\htdocs\control>composer require phpoffice/phpword It
downloaded successfully (at least without errors, files and folders appeared. Version - 0.15.0). But I don't understand how to run it in a script. For example, PhpSpreadsheet runs successfully like this:
require_once 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
require_once 'vendor/autoload.php';
use PhpOffice\PhpWord\Word;
use PhpOffice\PhpWord\Writer\Docx;
require_once 'vendor/autoload.php';
\PhpOffice\PhpWord\Autoloader::register();
require_once 'vendor\phpoffice\phpword\src\PhpWord\PhpWord.php';
require_once 'vendor\phpoffice\phpword\bootstrap.php';
Answer the question
In order to leave comments, you need to log in
Well, do you have to use/import the \PhpOffice\PhpWord\PhpWord class?
require_once 'vendor/autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
require_once 'vendor/autoload.php';
use PhpOffice\PhpWord\PhpWord;
$phpWord = new PhpWord();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question