PHPackages                             egeniq/php-markup-kit - 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. egeniq/php-markup-kit

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

egeniq/php-markup-kit
=====================

PHP MarkupKit: Parse HTML to a flexible structure.

v1.3.3(9mo ago)177MITPHPPHP ^8.4

Since Jul 23Pushed 9mo agoCompare

[ Source](https://github.com/egeniq/php-markup-kit)[ Packagist](https://packagist.org/packages/egeniq/php-markup-kit)[ RSS](/packages/egeniq-php-markup-kit/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (7)Dependencies (4)Versions (8)Used By (0)

PHP MarkupKit
=============

[](#php-markupkit)

PHP MarkupKit is a library for parsing HTML into a flexible (component) structure. and manipulating markup (such as HTML) in PHP. It provides a flexible API for working with markup structures, components, and attributed strings.

Features
--------

[](#features)

- Parse HTML to flexible component structures
- Represent phrasing markup as attributed strings
- Encode attributed strings to text, HTML and Markdown
- Extensible architecture for custom components

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

[](#installation)

Install via Composer:

```
composer require egeniq/php-markup-kit
```

Usage Example
-------------

[](#usage-example)

If you want to simply parse a string with HTML tags for simple formatting, linking and images you can use the following code:

```
use MarkupKit\Standard\Parsers\StringBundle;
use MarkupKit\Standard\String\FormatAttribute;
use MarkupKit\Core\Options;
use MarkupKit\Core\Parser;
use MarkupKit\Core\String\AttributedSubstring;

$parser = new Parser();
$options = new Options(new StringBundle());
$components = $parser->parse("Hello World!", $options);

assert(count($components) === 1);
$string = $components[0];

assert(count($string->elements) === 1);
assert($string->elements[0] instanceof AttributedSubstring);
assert($string->elements[0]->string === 'Hello World!');
assert($string->elements[0]->attributes->hasAttribute(FormatAttribute::Bold));
```

If you want to build a more complex component structure, you can use the provided basic implementation as a starting point:

```
use MarkupKit\Standard\Parsers\ComponentBundle;
use MarkupKit\Standard\Components;
use MarkupKit\Standard\String\FormatAttribute;
use MarkupKit\Core\Options;
use MarkupKit\Core\Parser;
use MarkupKit\Core\String\AttributedSubstring;

$parser = new Parser();
$options = new Options(new ComponentBundle());
$components = $parser->parse('Hello World! ', $options);

assert(count($components) === 2);

assert($components[0] instanceof Components\Text);
$string = $components[0]->content;
assert(count($string->elements) === 1);
assert($string->elements[0] instanceof AttributedSubstring);
assert($string->elements[0]->string === 'Hello World!');
assert($string->elements[0]->attributes->hasAttribute(FormatAttribute::Bold));

assert($components[1] instanceof Components\Image);
assert($components[1]->src === 'https://picsum.photos/id/237/200/300.jpg');
assert($components[1]->alt === 'Image');
```

Encoding attributed strings back to HTML or Markdown is also straightforward:

```
use MarkupKit\Standard\Parsers\StringBundle;
use MarkupKit\Core\Options;
use MarkupKit\Core\Parser;
use MarkupKit\Core\String\Encoder\Html\HtmlEncoder;
use MarkupKit\Core\String\Encoder\Markdown\MarkdownEncoder;

$parser = new Parser();
$options = new Options(new StringBundle());
$components = $parser->parse("Hello World!", $options);
$string = $components[0];

$htmlEncoder = new HtmlEncoder();
$html = $htmlEncoder->encode($string);
echo $html ."\n"; // Hello World!

$markdownEncoder = new MarkdownEncoder();
$markdown = $markdownEncoder->encode($string);
echo $markdown . "\n"; // **Hello World!**
```

More usage examples can be found in the [tests](tests/) directory.

Directory Structure
-------------------

[](#directory-structure)

- `src/MarkupKit/Core/` - HTML parser and other core functionality
- `src/MarkupKit/Standard/` - Standard implementation for parsing to components or attributed strings
- `tests/` - Unit tests

Contributing
------------

[](#contributing)

Pull requests and issues are welcome. Please see the [CONTRIBUTING](CONTRIBUTING.md) guidelines.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance57

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~8 days

Total

7

Last Release

286d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/353795?v=4)[Peter Verhage](/maintainers/petercv)[@petercv](https://github.com/petercv)

---

Top Contributors

[![petercv](https://avatars.githubusercontent.com/u/353795?v=4)](https://github.com/petercv "petercv (8 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/egeniq-php-markup-kit/health.svg)

```
[![Health](https://phpackages.com/badges/egeniq-php-markup-kit/health.svg)](https://phpackages.com/packages/egeniq-php-markup-kit)
```

###  Alternatives

[querypath/querypath

HTML/XML querying and processing (like jQuery)

8197.1M27](/packages/querypath-querypath)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[silverstripe/framework

The SilverStripe framework

7223.7M2.7k](/packages/silverstripe-framework)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M396](/packages/drupal-core-recommended)[roundcube/roundcubemail

The Roundcube Webmail suite

7.0k1.4k3](/packages/roundcube-roundcubemail)

PHPackages © 2026

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