Download the PHP package mkgrow/docx-merge without Composer

On this page you can find all versions of the php package mkgrow/docx-merge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package docx-merge

DocxMerge

CI PHP 8.2+

A framework-agnostic PHP 8.2+ Composer library that merges DOCX documents by substituting ${MARKER} placeholders in a template with content extracted from source .docx files. Supports multi-section extraction, style deduplication, numbering resequencing, media copying, and header/footer merging -- all while maintaining valid OOXML document structure.

Requirements

Requirement Version
PHP >= 8.2
ext-zip *
ext-dom *
ext-xml *
ext-mbstring *
psr/log ^3.0

Installation

Quick Start

The template document must contain ${MARKER} placeholders (e.g., ${INTRODUCTION}, ${CONCLUSION}) as paragraph text. Each placeholder is replaced with the full body content of the corresponding source DOCX file.

Usage

Simple single-marker merge

Multiple markers with different sources

Section targeting with MergeDefinition

When a source document has multiple sections, use MergeDefinition to extract a specific section by its zero-based index:

Configuring MergeOptions

Strict marker mode

Throws MarkerNotFoundException when a marker is not found in the template, instead of silently skipping it:

Custom marker pattern

Override the default ${MARKER} pattern with a custom regex. The first capture group must contain the marker name:

Reprocessing mode

Merge additional markers into a previously generated output file:

Handling the MergeResult

MergeResult provides structured feedback about the merge operation:

Error handling with typed exceptions

All exceptions extend DocxMergeException, allowing both broad and fine-grained error handling:

Using a PSR-3 logger

Pass any PSR-3 compatible logger to receive diagnostic output:

API Reference

Class Description Documentation
DocxMerger Public facade with merge() method docs/api/docx-merger.md
MergeDefinition DTO for marker-to-source binding with section targeting docs/api/merge-definition.md
MergeOptions DTO for merge configuration (pattern, strict mode, reprocessing) docs/api/merge-options.md
MergeResult DTO for merge results (success, stats, errors, warnings) docs/api/merge-result.md
Exceptions 6 typed exceptions extending DocxMergeException docs/api/exceptions.md

Architecture Overview

DocxMerge follows a 4-layer architecture with strict downward dependency flow:

Layer Components Responsibility
1. Public API DocxMerger, DTOs Entry point, input validation, normalization
2. Orchestration MergeOrchestrator, MergeContext 13-phase pipeline coordination, per-operation state
3. Domain Services 12 services (e.g., MarkerLocator, StyleMerger, IdRemapper) Individual merge concerns (styles, numbering, media, relationships)
4. Infrastructure XmlHelper, ZipHelper, IdTracker, SourceDocumentCache XML/ZIP utilities, ID tracking, document caching

All domain services depend on interfaces and are stateless (per ADR-001). Per-operation mutable state is encapsulated in MergeContext.

For complete architecture documentation, see docs/system-design/.

Development

Prerequisites

Setup

Commands

Command Description
composer test Run the full Pest v3 test suite
composer test --filter=Name Run a specific describe block or test
composer test:coverage Run tests with coverage gate (minimum 90%)
composer analyse Run PHPStan level 8 on src/ and tests/
composer format Apply PSR-12 formatting via php-cs-fixer
composer format:check Check PSR-12 compliance without modifying files
composer ci Full quality gate: analyse + format:check + test:coverage

Testing

The test suite uses Pest v3 with 182 tests and 357 assertions, achieving 95.2% line coverage.

Quality Gate

Before submitting changes, ensure the full CI pipeline passes:

This runs PHPStan level 8, PSR-12 format check, and test coverage gate (minimum 90%) in sequence.

Changelog

See CHANGELOG.md for a detailed version history.

License

This project is licensed under the MIT License. See the LICENSE file for details.


All versions of docx-merge with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-dom Version *
ext-mbstring Version *
ext-xml Version *
ext-zip Version *
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mkgrow/docx-merge contains the following files

Loading the files please wait ...