silverslice / docx-template
Replace variables in docx document
Installs: 3 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 5
Forks: 5
Open Issues: 0
Requires
- php: >=5.5
- ext-zip: *
Requires (Dev)
- phpunit/phpunit: ^8.5
README
Install
composer require silverslice/docx-template
Usage
Place variables in your docx-document as {foo}. Then replace them with replace
method. Use replaceMultiline
to replace variables with multiline strings.
use Silverslice\DocxTemplate\Template; require __DIR__ . '/vendor/autoload.php'; $template = new Template(); // open docx file $template->open('test.docx') // replace one variable to another ->replace('one', 'two') // replace once more ->replace('foo', 'bar') // replace with multiline string ->replaceMultiline('foo', 'one two three') // save docx document ->save('test.docx');