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(12mo ago)02.0k2MITPHPPHP ^8.4CI passing

Since Mar 11Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/metamorph)[ Packagist](https://packagist.org/packages/decodelabs/metamorph)[ RSS](/packages/decodelabs-metamorph/feed)WikiDiscussions develop Synced 1w 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 90% of packages

Maintenance68

Regular maintenance activity

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

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

360d 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 (164 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

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.2B15.1k](/packages/symfony-console)[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[symfony/http-foundation

Defines an object-oriented layer for the HTTP specification

8.7k950.4M7.1k](/packages/symfony-http-foundation)[symfony/var-dumper

Provides mechanisms for walking through any arbitrary PHP variable

7.4k922.8M10.2k](/packages/symfony-var-dumper)[twig/twig

Twig, the flexible, fast, and secure template language for PHP

8.4k473.8M7.7k](/packages/twig-twig)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k257.3M12.4k](/packages/symfony-framework-bundle)

PHPackages © 2026

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