muhammadsiyab/editorjs-parser-php

PHP parser for editorjs library

v1.0.1 2024-04-01 22:44 UTC

This package is auto-updated.

Last update: 2025-06-30 14:02:19 UTC


README

This package allows you to easily parse Editor.js JSON output to HTML using PHP. This package is currently able to parse the blocks from these plugins:

Requirements

PHP >=7.4

Installation

composer require muhammadsiyab/editorjs-parser-php

Using

require "vendor/autoload.php";


use MuhammadSiyab\EditorjsParserPhp\Parser;


# The json output generated by Editor.js
$content = '{"time": 1711232666978,"blocks": [{...}]}' ;

$parser = new Parser();
$parsed = $parser->parse($content);

echo $parsed; // outputs the generated HTML

Allow only specific blocks for parsing

# Only parses the `headings` and `paragraphs`

$parsed = $parser
            ->only('header', 'paragraph') // can be parsed using the array syntax ['header', 'paragraph']
            ->parse($content);

Disable specific blocks from being parsed

# Parses all the blocks except `list` and `code`

$parsed = $parser
            ->except('list', 'code') // can be parsed using the array syntax ['list', 'code']
            ->parse($content);

License

This Package is open-sourced software licensed under the MIT license