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


        'providers' => [
        ...
            Novay\WordTemplate\WordTemplateServiceProvider::class,
        ];

        'aliases' => [
        ...
           'WordTemplate' => Novay\WordTemplate\Facade::class, 
        ];
    

    Route::get('/', function () {
		$file = public_path('surat_pernyataan.rtf');
		
		$array = array(
			'[NOMOR_SURAT]' => '015/BT/SK/V/2017',
			'[PERUSAHAAN]' => 'CV. Borneo Teknomedia',
			'[NAMA]' => 'Melani Malik',
			'[NIP]' => '6472065508XXXX',
			'[ALAMAT]' => 'Jl. Manunggal Gg. 8 Loa Bakung, Samarinda',
			'[PERMOHONAN]' => 'Permohonan pengurusan pembuatan NPWP',
			'[KOTA]' => 'Samarinda',
			'[DIRECTOR]' => 'Noviyanto Rahmadi',
			'[TANGGAL]' => date('d F Y'),
		);

		$nama_file = 'surat-keterangan-kerja.doc';
		
		return WordTemplate::export($file, $array, $nama_file);
	});

    Route::get('/', function () {
		$file = public_path('surat_pernyataan.rtf');
		
		$array = array(
			'[NOMOR_SURAT]' => '015/BT/SK/V/2017',
			'[PERUSAHAAN]' => 'CV. Borneo Teknomedia',
			'[NAMA]' => 'Melani Malik',
			'[NIP]' => '6472065508XXXX',
			'[ALAMAT]' => 'Jl. Manunggal Gg. 8 Loa Bakung, Samarinda',
			'[PERMOHONAN]' => 'Permohonan pengurusan pembuatan NPWP',
			'[KOTA]' => 'Samarinda',
			'[DIRECTOR]' => 'Noviyanto Rahmadi',
			'[TANGGAL]' => date('d F Y'),
		);

		$nama_file = 'surat-keterangan-kerja.doc';
		
		return WordTemplate::export($file, $array, $nama_file);
	});

	WordTemplate::export('file.rtf', array(), 'nama_file.doc');

	WordTemplate('file.rtf', array(), 'nama_file.doc');