Laravel 6 Generate Word File

Feb 11, 2020



Laravel 6 Generate Word File

Hi Guys,

In this blog, I will explain how to generate a word document file in laravel. we will show the example of create word document file in can easy to generate word file in laravel.we will generate *.doc file without using any composer package. I will generate doc file from html content in laravel 5 application.

We might be some time require to create docs file from database in laravel. if you need to same requirement then you can easily achieve to generate word document.We will use headers with Html content and file name will be *.docx. we can use simple html tag like p, strong, ul, li, etc. that all tags will support for creating docs file. you can follow this tutorial to create a simple way docs file.

Here i give you full example of generate word document file example like create route. So you have to just follow example.

Create Route:

Now,we need to create route for generate word document file in laravel.So following add route fille path.

following path:/routes/web.php


Route::get('generate-docs', function(){

$headers = array(




$content = '<html>

<head><meta charset="utf-8"></head>


<p>My Blog -</p>




return \Response::make($content,200, $headers);


It will help you...

#Laravel 6