PHPackages                             decodelabs/metamorph - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. decodelabs/metamorph

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

decodelabs/metamorph
====================

A flexible framework for content transformations

v0.8.0(8mo ago)02.0k2MITPHPPHP ^8.4CI passing

Since Mar 11Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/metamorph)[ Packagist](https://packagist.org/packages/decodelabs/metamorph)[ RSS](/packages/decodelabs-metamorph/feed)WikiDiscussions develop Synced 4w ago

READMEChangelog (10)Dependencies (10)Versions (33)Used By (2)

Metamorph
=========

[](#metamorph)

[![PHP from Packagist](https://camo.githubusercontent.com/dd2d0827975136bec62503535008366a7ef0bcdfda54e8e904fccd2acc079628/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f6d6574616d6f7270683f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/metamorph)[![Latest Version](https://camo.githubusercontent.com/2047330188b488b523f23dcb39e17efd577ac7acc13f2fcd41f36c9f33050262/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f6d6574616d6f7270682e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/metamorph)[![Total Downloads](https://camo.githubusercontent.com/86efe099f16790a4cb74eb4af6750e56da2a8b99dba34e569260c2ffd7d60c92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f6d6574616d6f7270682e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/metamorph)[![GitHub Workflow Status](https://camo.githubusercontent.com/b72a93a93092bbd02dfed0cf710ef58e4406a37286527066b94bf19ad57a626c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f6d6574616d6f7270682f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/metamorph/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/4bb95213a3410e5b43fda04b51d8d0202eb6f925abb165cfa84a45ad2ec5186d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f6d6574616d6f7270683f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/metamorph)

### A flexible framework for content transformations

[](#a-flexible-framework-for-content-transformations)

Metamorph provides an extensible framework for transforming content from one format to another through a simple and intuitive interface.

---

Installation
------------

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/metamorph
```

Usage
-----

[](#usage)

### Transformations

[](#transformations)

Use the Metamorph frontage to manipulate and output different formats of content.

Options can be passed as the second parameter and named macros allow for bundles of options to be passed as part of the call.

Metamorph uses [Archetype](https://github.com/decodelabs/archetype) to load `Handler` classes - the base package comes with a small set of handlers out of the box:

### Markdown

[](#markdown)

The built-in Markdown Handler will use whichever appropriate Markdown library has been installed via composer.

```
use DecodeLabs\Metamorph;

// Default Markdown renders
echo Metamorph::markdown($markdownContent);

// Ensure output is secure from exploits with "safe" macro
echo Metamorph::{'markdown.safe'}($markdownContent);

// Output inline markup
echo Metamorph::{'markdown.inline'}($markdownContent);
```

### Text

[](#text)

The Text Handler considers input to be plain text and allows for various manipulations. HTML wrapping is turned on by default, converting the text to Tagged Markup.

```
echo Metamorph::text('Hello world', [
    'maxLength' => 5 // shorten output with ellipsis
    'ellipsis' => '...' // Character(s) used while shortening string (optional)
    'wrap' => true // Wrap output as HTML markup
]);

// wrap=false
echo Metamorph::{'text.raw'}($longText);

// maxLength=50, wrap=true
echo Metamorph::{'text.preview'}($longText);

// maxLength=50, wrap=false
echo Metamorph::{'text.preview.raw'}($longText);
```

### HtmlToText

[](#htmltotext)

The HtmlToText Handler works in the opposite direction, taking HTML input and converting it to readable plain text.

```
echo Metamorph::htmlToText('This is an HTML paragraph', [
    'maxLength' => 5 // shorten stripped output with ellipsis
    'ellipsis' => '...' // Character(s) used while shortening string (optional)
    'wrap' => true // Wrap the stripped text in Markup element
]);

// Strip and re-wrap HTML
echo Metamorph::{'htmlToText.wrap'}($html);

// maxLength=50, wrap=true
echo Metamorph::{'htmlToText.preview'}($html);
```

Other implementations
---------------------

[](#other-implementations)

See [Idiom](https://github.com/decodelabs/idiom) and [Chirp](https://github.com/decodelabs/chirp) for other custom implementations of Metamorph Handlers.

Licensing
---------

[](#licensing)

Metamorph is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance71

Regular maintenance activity

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~42 days

Recently: every ~29 days

Total

31

Last Release

260d ago

PHP version history (4 changes)v0.1.0PHP ^7.2|^8.0

v0.4.0PHP ^8.0

v0.5.2PHP ^8.1

v0.7.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (160 commits)")

---

Tags

content-transformationmarkdownphptext-to-htmlcontenttransformrender

### Embed Badge

![Health badge](/badges/decodelabs-metamorph/health.svg)

```
[![Health](https://phpackages.com/badges/decodelabs-metamorph/health.svg)](https://phpackages.com/packages/decodelabs-metamorph)
```

###  Alternatives

[doctrine/rst-parser

PHP library to parse reStructuredText documents and generate HTML or LaTeX documents.

64233.6k9](/packages/doctrine-rst-parser)[davidbadura/markdown-builder

Markdown Builder

22899.4k5](/packages/davidbadura-markdown-builder)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

44127.5k6](/packages/jstewmc-rtf)[atanamo/php-codeshift

A PHP code transformation toolkit based on 'PHP-Parser'

32158.4k1](/packages/atanamo-php-codeshift)[kendall-hopkins/formal-theory

FormalTheory is a library that allows for manipulation and conversion of NFAs, DFAs and Regular Expressions.

335.4k](/packages/kendall-hopkins-formal-theory)[cartalyst/interpret

A driver-based content rendering package, with support for HTML, Markdown &amp; plain text. You can register custom drivers for custom content types.

1914.7k](/packages/cartalyst-interpret)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
