PHPackages                             bpstr/editorjs-renderer-php - 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. bpstr/editorjs-renderer-php

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

bpstr/editorjs-renderer-php
===========================

Simple parser and renderer backend for Editor.js

291[1 PRs](https://github.com/bpstr/editorjs-renderer-php/pulls)PHPCI failing

Since Feb 8Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/bpstr/editorjs-renderer-php)[ Packagist](https://packagist.org/packages/bpstr/editorjs-renderer-php)[ RSS](/packages/bpstr-editorjs-renderer-php/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (2)Used By (0)

editorjs-renderer-php
=====================

[](#editorjs-renderer-php)

An extendable PHP renderer for the [Editor.js](https://editorjs.io/) which works well with the [Editor.js PHP backend](https://github.com/editor-js/editorjs-php).

Getting Started
===============

[](#getting-started)

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

[](#installation)

Install the package using Composer:

```
composer require bpstr/editorjs-renderer-php:dev-master

```

Basic usage
-----------

[](#basic-usage)

```
use Bpstr\EditorJs\EditorJsRenderer;
$renderer = EditorJsRenderer::withBlocks($blocks);
```

The EditorJsRenderer class uses two required parameters:

- `mapping`: The block classes (or instances) keyed by the block type from the CodeX Editor.

```
Bpstr\EditorJs\EditorJsRenderer::$default_mapping = [
    'header' => HeaderBlock::class,
    'image' => ImageBlock::class,
    'paragraph' => ParagraphBlock::class,
    'quote' => QuoteBlock::class,
    // ...
];
```

- `blocks`: Array having the same structure as one returned by `EditorJS::getBlocks()`

```
$blocks = [
    ['type' => 'heading', 'data' => ['text' => 'Dolor sit amet.']],
    ['type' => 'paragraph', 'data' => ['text' => 'Lorem ipsum']]
];
```

*Almost every Editor.Js block plugin already have the matching classes bundled and tested in the package.*

Rewrite the mapping
-------------------

[](#rewrite-the-mapping)

In case you would like to alter the Renderer, you can add or replace the mapped renderer blocks.

### Providing static mapping

[](#providing-static-mapping)

Calling this method will create instances of all the default classes plus the ones you provide.

```
$renderer = EditorJsRenderer::withBlocks($blocks, ['code' => ColoredCodeBlock::class]);
```

### Replace mapping

[](#replace-mapping)

Using this method, no defaults will be added, the passed array will replace the inner mapping.

```
$renderer = EditorJsRenderer::withMapping(['code' => ColoredCodeBlock::class]);
```

### Mapping on the fly

[](#mapping-on-the-fly)

You can add block instances to the Renderer instance on the fly too.

```
$renderer->map('header', new \Bpstr\EditorJs\Block\HeaderBlock());
```

Rendering blocks
================

[](#rendering-blocks)

To get the HTML markup, just call the `render()` method.

```
echo $renderer->render();
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance53

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/37303771?v=4)[Fent Jani](/maintainers/bpstr)[@bpstr](https://github.com/bpstr)

### Embed Badge

![Health badge](/badges/bpstr-editorjs-renderer-php/health.svg)

```
[![Health](https://phpackages.com/badges/bpstr-editorjs-renderer-php/health.svg)](https://phpackages.com/packages/bpstr-editorjs-renderer-php)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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