PHPWord is on Packagist, so installing it on Laravel is as easy as:
composer require phpoffice/phpword
or adding this to your composer.json then running composer install
:
"require": {
"phpoffice/phpword": "dev-master"
}
Once installed, you can use it in your code like this (taken from the documentation):
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText(
htmlspecialchars(
'"Learn from yesterday, live for today, hope for tomorrow. '
. 'The important thing is not to stop questioning." '
. '(Albert Einstein)'
)
);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
$objWriter->save('helloWorld.html');