PHP code example of novay / laravel-word-template

1. Go to this page and download the library: Download novay/laravel-word-template library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

novay / laravel-word-template example snippets


return Word::template(storage_path('app/templates/replace-values.docx'))
    ->setValue('nama', 'Novianto Rahmadi')
    ->setValue('app', 'Laravel WordTemplate')
    ->download('output.docx');

return Word::template(storage_path('app/templates/template.docx'))
    ->setImage('logo', public_path('logo.png'), [
        'width' => 120,
        'height'=> 120,
        'ratio' => true
    ])
    ->download('output.docx');
bash
php artisan vendor:publish --provider="Novay\Word\Providers\WordServiceProvider"