nowo-tech / html-to-word-bundle
Symfony bundle: HTML (WYSIWYG output) → DOCX with named YAML profiles, PHPWord, sanitization and tagged transformers.
Package info
github.com/nowo-tech/HtmlToWordBundle
Type:symfony-bundle
pkg:composer/nowo-tech/html-to-word-bundle
Requires
- php: >=8.2 <8.6
- ext-dom: *
- ext-json: *
- ext-libxml: *
- league/flysystem: ^3.16
- masterminds/html5: ^2.9
- phpoffice/phpword: ^1.3
- symfony/config: ^6.4 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.0 || ^8.0
- symfony/http-foundation: ^6.4 || ^7.0 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.0
- symfony/framework-bundle: ^6.4 || ^7.0 || ^8.0
- symfony/yaml: ^6.4 || ^7.0 || ^8.0
This package is auto-updated.
Last update: 2026-05-07 09:07:47 UTC
README
⭐ Found this useful? Install from Packagist (
composer require nowo-tech/html-to-word-bundle) and consider starring HtmlToWordBundle on GitHub.
Symfony bundle that converts rich HTML (WYSIWYG output from TipTap, CKEditor, etc.—already rendered server-side) into a downloadable .docx using PHPWord, with:
- named YAML profiles + default profile + deep merge with per-call options, or
convertWithInlineProfile()for a full stored profile (no YAML merge); - sanitization and HTML5 parsing (masterminds/html5);
- tagged transformers for block elements (
p, headings, lists, tables, images, …); - remote & inline images — optional download of
http(s)://<img src>to temp paths before PhpWord, with cleanup after DOCXsave; - optional header/footer (logo, text, page numbers) per profile;
- Symfony-friendly export: streamed/binary responses, local path, optional Flysystem.
This bundle does not render Twig, generate HTML, produce PDF, or edit existing Word files.
Documentation
Additional documentation
- FrankenPHP demos — how
demo/symfony7runs in Docker. - Example YAML profiles are shipped as
src/Resources/config/nowo_html_to_word.yaml(copy into your app’sconfig/packages/).
Requirements
- PHP 8.2+
- Symfony 6.4 / 7.x / 8.x (components declared in
composer.json) - Extensions:
dom,json,libxml
Quick start
composer require nowo-tech/html-to-word-bundle
Register Nowo\HtmlToWordBundle\HtmlToWordBundle if Flex does not, then add config/packages/nowo_html_to_word.yaml (see Configuration).
use Nowo\HtmlToWordBundle\Converter\HtmlToWordConverterInterface; use Nowo\HtmlToWordBundle\Export\ExporterInterface; $doc = $converter->convert($html); return $exporter->toStreamResponse($doc);
Tests and coverage
| Scope | Detail |
|---|---|
| PHPUnit | composer test — unit tests under tests/Unit, integration tests under tests/Integration (minimal Symfony kernel in tests/Fixtures/AppKernel.php). |
| PHP lines | Run composer test-coverage for the console summary, or composer coverage-check (same report written to coverage-output.txt, fails below 93% global lines). Latest reported global line coverage: ~94% (PCOV; a few defensive branches in exporters / image temp paths are marked @codeCoverageIgnore where impractical to hit in CI). |
CI runs tests, PHPStan, and PHP-CS-Fixer on push/PR (see .github/workflows/ci.yml).
Development
Use the root Makefile and docker-compose.yml:
make up make qa make release-check
The PHP Docker image installs extensions required by PHPWord (including GD). Demo apps live under demo/ (see docs/DEMO-FRANKENPHP.md).
Version information
Stable releases are tagged on GitHub; upgrade notes are in docs/UPGRADING.md and docs/CHANGELOG.md.
Versioning
This library follows Semantic Versioning.
License
Released under the MIT License.