PHPackages                             maxpertici/markup - 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. [Templating &amp; Views](/categories/templating)
4. /
5. maxpertici/markup

ActiveLibrary[Templating &amp; Views](/categories/templating)

maxpertici/markup
=================

A flexible system for building and rendering HTML markup structures

0.9.3(2mo ago)1191MITPHPPHP &gt;=8.1CI passing

Since Nov 14Pushed 2mo agoCompare

[ Source](https://github.com/maxpertici/markup)[ Packagist](https://packagist.org/packages/maxpertici/markup)[ RSS](/packages/maxpertici-markup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (21)Used By (1)

Markup
======

[](#markup)

[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/1a5e13126d38c1d05f712dae30e7f60ae0444a9c882e9e526349ccba27facb8d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e312d626c7565)](https://www.php.net/)

📚 **[Complete Documentation](https://maxpertici.github.io/markup/)** | [Getting Started](https://maxpertici.github.io/markup/getting-started) | [Markup](https://maxpertici.github.io/markup/markup) | [MarkupFactory](https://maxpertici.github.io/markup/markup-factory) | [MarkupSlot](https://maxpertici.github.io/markup/markup-slot) | [MarkupFinder](https://maxpertici.github.io/markup/markup-finder)

A flexible and intuitive PHP library for building HTML markup structures using a fluent, chainable API. Parse existing HTML, modify and manipulate it easily, or create reusable components with slots, manage CSS classes and attributes, and render HTML efficiently.

Introduction
------------

[](#introduction)

**Markup** provides a modern, object-oriented approach to handling HTML in PHP. Instead of mixing HTML strings or using complex templating engines, Markup offers:

- ✨ **Fluent API** - Chain methods for intuitive markup building
- 🎯 **Slot System** - Named placeholders like Vue.js or Laravel Blade
- 🎨 **CSS Class Management** - Add, remove, check classes easily
- ⚙️ **HTML Attributes** - Full control over element attributes
- 🔄 **Nested Components** - Compose complex structures from simple parts
- 🚀 **Dual Rendering** - `render()` to return string, `print()` for streaming
- 🔁 **Conditional &amp; Loop Helpers** - `when()` and `each()` for dynamic content
- 🔍 **Search &amp; Find** - Query your markup tree with CSS selectors
- 📦 **Zero Dependencies** - Pure PHP, no external requirements

Perfect for building reusable UI components, generating dynamic HTML, or creating a component library for your PHP applications.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher

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

[](#installation)

Install via Composer:

```
composer require maxpertici/markup
```

Getting Started
---------------

[](#getting-started)

### Quick Example

[](#quick-example)

```
