Download the PHP package mkgrow/content-control without Composer

On this page you can find all versions of the php package mkgrow/content-control. 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 content-control

ContentControl

Build Status Tests PHP Version

Portuguese version: readme.pt-BR.md

ContentControl is a PHP library that extends PHPOffice/PHPWord to add Word Content Controls (Structured Document Tags/SDTs) to .docx files. It enables document-level content protection and metadata tagging conforming to ISO/IEC 29500-1:2016 §17.5.2.

Table of Contents

Installation

Install via Composer:

Requirements:

Quick Start

Creating a New Document with Content Controls

Modifying Existing Documents

Building Tables with Content Controls (v0.6.0+)

For more examples, see the samples/ directory.

Features

Core Capabilities:

PHP Compatibility:

Quality Standards:

Supported Content Control Types:

Lock Types:

Supported PHPWord Elements:

Documentation

Architecture Overview

ContentControl follows a composition-based architecture with no inheritance hierarchies. All 8 core classes are final, promoting extension via composition rather than inheritance.

Design Philosophy:

Core Patterns:

Version Evolution:

Core Components

1. ContentControl

Purpose: Facade/proxy for PHPWord that adds SDT registration and injection capabilities.

Location: src/ContentControl.php

Key Methods:

Workflow:

  1. Create document via PHPWord delegation
  2. Register elements with addContentControl()
  3. Save - triggers SDTInjector to wrap elements in DOM
  4. Modified XML written to DOCX ZIP

Example:

For detailed documentation, see docs/contentcontrol.md.

2. ContentProcessor

Purpose: Open and modify existing DOCX files via XPath-based SDT manipulation.

Location: src/ContentProcessor.php

Key Methods:

Workflow:

Important: ContentProcessor is single-use. After save(), the ZIP is closed and no further modifications are possible. Create a new instance for additional changes.

For detailed documentation, see docs/contentprocessor.md.

3. TableBuilder

Purpose: Bridge pattern for creating PHPWord tables with Content Controls and injecting into templates.

Location: src/Bridge/TableBuilder.php

Two Distinct Workflows:

Workflow 1: Direct Creation with v2 API (v0.6.0+) (recommended)

Workflow 2: Template Injection (build table, inject into template placeholder)

Critical Rules:

v2 API (v0.6.0+):

Legacy Fluent API (deprecated since v0.6.0, removal in v0.8.0):

See Migration Guide for fluent-to-direct API migration examples.

For detailed documentation, see docs/TableBuilder.md.

Configuration

SDT Configuration Options

All Content Controls support the following configuration options:

ID Constraints:

Type Constants:

Lock Type Constants:

Inline Level Flag:

Run Level Flag (v0.6.0+):

Table Styles Configuration

Important: setStyles() must be called BEFORE first addRow() call. Throws ContentControlException if table already exists.

Error Handling

Exception Hierarchy

All library-specific exceptions extend MkGrow\ContentControl\Exception\ContentControlException:

Exception Types:

Exception Thrown When Example Scenario
ContentControlException General library errors Invalid configuration, duplicate elements
DocumentNotFoundException word/document.xml missing from DOCX Corrupted ZIP archive
ZipArchiveException ZIP manipulation failures File permissions, disk space
TemporaryFileException Temp file cleanup fails after 3 retries Windows file locks
InvalidArgumentException Invalid parameters Duplicate IDs, invalid SDT types
RuntimeException DOM/XML processing errors Malformed XML, serialization failures

Best Practices:

Common Error Scenarios:

  1. Duplicate Element Registration:

  2. Duplicate ID:

  3. Invalid ID Format:

  4. Missing inlineLevel for Cell SDTs:

  5. setStyles After addRow:

  6. injectInto on ContentControl:

Logging and Debugging

DOCX Inspection

DOCX files are ZIP archives containing XML. To inspect generated Content Controls:

Windows PowerShell:

Linux/macOS Bash:

Expected SDT Structure

Valid Content Control XML (ISO/IEC 29500-1:2016 §17.5.2):

Block-level SDT (wraps <w:p>, <w:tbl>, <w:tc>):

Run-level SDT (v0.6.0+) (wraps <w:r> inside <w:p>, CT_SdtContentRun):

Common Debugging Scenarios

  1. Duplicate SDTs:

    • Symptom: Multiple <w:sdt> wrappers around same element
    • Cause: Using v2.x string replacement (deprecated)
    • Check: Verify SDTInjector::$processedElements registry marks element before wrapping
    • Solution: Upgrade to v3.0+ with DOM manipulation
  2. Missing SDTs:

    • Symptom: Element not wrapped with SDT in output
    • Cause: ElementLocator XPath query doesn't match element
    • Debug: Check findElementInDOM() return value, verify element type and order
    • Solution: Ensure element type is supported, check registration order
  3. Malformed XML:

    • Symptom: Word cannot open file, reports corruption
    • Cause: Invalid XML structure or namespace issues
    • Debug: Use libxml_get_errors() after DOMDocument::loadXML()
    • Solution: Validate XML with xmllint --noout temp/word/document.xml
  4. Namespace Pollution:
    • Symptom: Redundant xmlns:w declarations in SDT elements
    • Cause: Manual XML string creation instead of DOM methods
    • Solution: Use createElementNS() with namespace URI, relies on root inheritance

PHPStan Analysis

Run PHPStan Level 9 analysis to catch type errors:

Output includes line-specific errors with context. Fix issues before committing.

Element Cache Statistics

For advanced debugging, inspect element identification cache:

Testing

Running Tests

The project uses Pest for testing with 559+ tests and 82%+ code coverage.

All Tests:

Unit Tests Only:

Feature Tests Only:

Coverage Report (Enforces 80% Minimum):

HTML Coverage Report:

Test Structure

Unit Tests (tests/Unit/):

Feature Tests (tests/Feature/):

Key Test Categories:

Custom Pest Expectations

The test suite includes custom expectations defined in tests/Pest.php:

Static Analysis

PHPStan Level 9:

Combined CI Check (Analysis + Coverage):

Full Check (Analysis + All Tests):

Manual Testing in Word

After generating DOCX files, verify in Microsoft Word:

  1. Open Developer Tab: File → Options → Customize Ribbon → Enable Developer
  2. View Content Controls: Developer → Design Mode
  3. Check Properties: Click SDT → Properties button
  4. Test Protection: Try editing/deleting locked SDTs
  5. Verify Display Names: Hover over SDT to see alias

For comprehensive Word testing checklist, see docs/MANUAL_TESTING_GUIDE.md.

Changelog and Contributing

Changelog: See CHANGELOG.md for version history and release notes.

Detailed v0.7.1 release notes: docs/0.x/CHANGELOG-v0.7.1.md

Contributing: See CONTRIBUTING.md for development guidelines, coding standards, and pull request process.

Code of Conduct: Be professional, respectful, and constructive. Focus on technical merit and project improvement.

Security

Reporting Vulnerabilities:

If you discover a security vulnerability in ContentControl, please DO NOT open a public issue or pull request.

Instead, report it privately via email to: [email protected]

Include:

We will respond within 48 hours and work with you to address the issue responsibly.

Security Best Practices:

Credits

Main Contributors:

Third-Party Assets:

Acknowledgments:

License

ContentControl is licensed under the MIT License. See LICENSE for details.


Documentation: docs/README.md
Samples: samples/README.md
GitHub: mateusbandeira182/ContentControl
Issues: GitHub Issues


All versions of content-control with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
phpoffice/phpword Version ^1.4
ramsey/uuid Version ^4.7
ext-dom Version *
ext-mbstring Version *
ext-zip Version *
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/content-control contains the following files

Loading the files please wait ...