PHPackages                             robertkleinschuster/mosaic - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. robertkleinschuster/mosaic

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

robertkleinschuster/mosaic
==========================

A Component Renderer for PHP

v0.0.1(1y ago)0912MITPHPPHP ^8.3

Since Feb 24Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (2)

Mosaic
======

[](#mosaic)

**A Component Renderer for PHP**

Mosaic is a state-of-the-art server-side rendering engine for PHP. It offers an enhanced approach to efficiently and flexibly build and render UI components. Designed specifically for PHP developers, it blends seamlessly with the language’s native capabilities to deliver a rich, component-oriented development experience.

Key Advantages
--------------

[](#key-advantages)

### Designed for PHP Developers

[](#designed-for-php-developers)

- **PHP-Native Experience**: Tailored for PHP without requiring adherence to an MVC model, Mosaic integrates smoothly into PHP projects, leveraging the language's strengths.

### Flexible Component Types

[](#flexible-component-types)

- **Versatile Component Strategies**: Beyond mere template rendering, Mosaic supports closures, fragments, and renderable objects, promoting modular and reusable design practices.

### Extensible and Customizable

[](#extensible-and-customizable)

- **Custom Strategies Out-of-the-Box**: The library enables custom rendering strategies for unmatched flexibility, perfect for projects with unique rendering needs.

### Lightweight and Performant

[](#lightweight-and-performant)

- **Minimal Overhead**: Designed to be lean, Mosaic delivers exceptional performance, suitable for projects ranging from small to large scale.

### Focused on Server-Side Rendering

[](#focused-on-server-side-rendering)

- **Optimized for Server-Side Efficiency**: Exclusively targeting server-side rendering, it exploits server capabilities for rapid response times and efficient resource use.

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

[](#installation)

Install through Composer:

```
composer require robertkleinschuster/mosaic
```

Usage
-----

[](#usage)

Here are examples for supported component types:

### String Components

[](#string-components)

Handle simple strings:

```
$renderer->render("Hello, world");
```

Strings are escaped by default, to render html use a fragment.

### Fragment Components

[](#fragment-components)

Compose UI fragments:

```
$fragment = $renderer->fragment('Hello, world');
$renderer->render($fragment);
```

### Closure Components

[](#closure-components)

Render PHP closures dynamically:

```
$renderer->render(function ($data) {
    return "Hello, " . $data['name'];
}, ['name' => 'world']);
```

The return value is evaluated as a component.

### Iterable Components

[](#iterable-components)

Loops over iterable of components:

```
$items = ['item1', 'item2', 'item3'];
$renderer->render($items);
```

This is typically used with the PHP generator syntax:

```
$items = ['item1', 'item2', 'item3'];
$renderer->render(function() {
    yield "first\n",
    yield "second\n",
    yield "third\n",
});
```

### Renderable Components

[](#renderable-components)

Utilize objects implementing the Renderable interface:

```
class MyComponent implements \Mosaic\Renderable {
    public function render(\Mosaic\Renderer $renderer, $data) {
        yield $renderer->fragment("Hello, {$data['name']}");
    }
}
$renderer->render(new MyComponent(), ['name' => 'world']);
```

In this example the PHP generator syntax is used to yield a child HTML fragment.

### Attribute Components

[](#attribute-components)

Wrap a class of closure another component using PHP-8 attributes.

```
#[Attribute]
class MyWrapper implements \Mosaic\RenderableAttribute {
    public function render(\Mosaic\Renderer $renderer, mixed $children, mixed $data){
        return $renderer->fragment( 'Hello world!')
```

The string "Hello world!" will now be rendered inside the paragraph defined in the MyWrapper component.

Passing parameters to components
--------------------------------

[](#passing-parameters-to-components)

```
$renderer->render(fn(string $name) => "Hello $name!", name: 'world')
```

Extending Mosaic
----------------

[](#extending-mosaic)

Its design allows for straightforward expansion, enabling developers to create custom rendering strategies, helper utilities, and more to meet specific application requirements.

Running Tests
-------------

[](#running-tests)

To execute the test suite, run the appropriate command in your CLI.

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

[](#contributing)

Contributions are highly appreciated, whether through issue reporting, feature suggestions, or direct code contributions.

License
-------

[](#license)

Distributed under the MIT License. See the LICENSE file for more information.

Getting Help
------------

[](#getting-help)

For questions, issues, or assistance, please open an issue on GitHub.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance46

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

439d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43c5aeaeb453ce57f8f4a9b4e57d788259527a9725b48d12a541fbb4ef5b7848?d=identicon)[robertkleinschuster](/maintainers/robertkleinschuster)

---

Top Contributors

[![robertkleinschuster](https://avatars.githubusercontent.com/u/64379246?v=4)](https://github.com/robertkleinschuster "robertkleinschuster (7 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/robertkleinschuster-mosaic/health.svg)

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

###  Alternatives

[symfony/polyfill-uuid

Symfony polyfill for uuid functions

688335.4M63](/packages/symfony-polyfill-uuid)[spatie/error-solutions

This is my package error-solutions

6853.2M11](/packages/spatie-error-solutions)[phpflo/phpflo

Flow-based programming for PHP

2173.3k4](/packages/phpflo-phpflo)[eftec/autoloadone

AutoloadOne is a program that generates an autoload class for PHP.

403.4k](/packages/eftec-autoloadone)[ys-tools/default-theme-configuration-bundle

OroCommerce Default Theme Configuration Bundle

124.2k](/packages/ys-tools-default-theme-configuration-bundle)

PHPackages © 2026

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