I made the following controller that fills a docx document with values.
namespace App\Controllers\Services
use App\Controllers\BaseController;
use Illuminate\Support\Facades\Response;
use PhpOffice\PhpWord\TemplateProcessor;
use PhpOffice\PhpWord\PhpWord;
class Contract extends BaseController
{
public function getContract()
{
$file = storage_path()."/contracts/contract.docx";
$tmpFile = storage_path()."/contracts/output.docx";
$template = new TemplateProcessor($file);
$template->setValue('COMP_NAME',"LOREM IPSUM INC");
$template->setValue('ADDRESS',"Nowhere Str Tsastikistan");
$template->saveAs($tmpFile);
return Response::make("OK");
ā¦