1. Go to this page and download the library: Download n1xez/php-stamp 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/ */
n1xez / php-stamp example snippets
use PHPStamp\Templator;
use PHPStamp\Document\WordDocument;
$cachePath = 'path/to/writable/directory/';
$templator = new Templator($cachePath);
// Enable debug mode to re-generate template with every render call.
// $templator->debug = true;
// Enable track mode to generate template with every original document change.
// $templator->trackDocument = true;
$documentPath = 'path/to/document.docx';
$document = new WordDocument($documentPath);
$values = [
'library' => 'PHPStamp 0.1',
'simpleValue' => 'I am simple value',
'nested' => [
'firstValue' => 'First child value',
'secondValue' => 'Second child value'
],
'header' => 'test of a table row',
'students' => [
['id' => 1, 'name' => 'Student 1', 'mark' => '10'],
['id' => 2, 'name' => 'Student 2', 'mark' => '4'],
['id' => 3, 'name' => 'Student 3', 'mark' => '7']
],
'maxMark' => 10,
'todo' => [
'TODO 1',
'TODO 2',
'TODO 3'
]
];
$result = $templator->render($document, $values);
// Now you can get template result.
// 1. HTTP Download
$result->download();
// Or
// 2. Save to file
// $saved = $result->save(__DIR__ . '/static', 'Test_Result1.docx');
// if ($saved === true) {
// echo 'Saved!';
// }
// Or
// 3. Buffer output
// echo $result->output();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.