How to fix - "Illegal string offset 'w:compatSetting'"

Yesterday, i was working on my php laravel 5 application and i installed PHPOffice/PHPWord package and trying to use it in controller. But when i run my project and see i got following error :

"Illegal string offset 'w:compatSetting'"

Even i generate docx file, i thought why it's come event file is created successfully. I try to understand deeply but i didn't get well. However i found temporary solution using try catch. So you can solve by following way:


$phpWord = new \PhpOffice\PhpWord\PhpWord();

$section = $phpWord->addSection();


$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');

try {


} catch (Exception $e) {


return response()->download(storage_path('helloWorld.docx'));

I hope you found your best solution

July 21, 2017 | Category : Laravel
Related Posts

Blog Search