denisristic / word-service-provider
A wrapper for PHPWord usage in Silex 2 projects
0.1.1
2016-09-21 11:08 UTC
Requires
- php: >=5.4.0
- doctrine/dbal: ^2.5
- phpoffice/phpword: ~0.13
- pimple/pimple: ~3.0
- silex/silex: ~2.0
This package is not auto-updated.
Last update: 2024-12-30 08:20:18 UTC
README
Introduction
This service provider for Silex allows you to quickly generate Word (*.doc) documents. Either pass in a query result set, and a list of headers, or use the Doctrine functionality to convert a html to a document.
Installation
Require the provider using composer
:
composer require denisristic/word-service-provider
Register the provider in your application somewhere:
$app->register(new \denisristic\WordServiceProvider\Provider\WordServiceProvider());
Usage
Generate a document from HTML:
$word = $app['word']->generateDOC('<h1>Test HTML header</h1>');
Forcing a download of the spreadsheet:
$controllers->get('/download', function () use($app) { $word = $app['word']->generateDOC('<h1>Test HTML header</h1>'); $docName = 'entries-' . date('Y-m-dhis') . '.doc'; $response = new Response($word); $response->headers->add(array( 'Content-Type' => 'application/vns.ms-word' ,'Content-Disposition' => 'inline; filename="' . $docName . '"' ,'Pragma' => 'no-cache' ,'Expired' => 0 )); return $response; })->bind('download');