hugo-levet/strapi-php-rich-text-parser

A PHP parser for Strapi Rich Text fields

Installs: 27

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

pkg:composer/hugo-levet/strapi-php-rich-text-parser

v1.3.3 2025-02-23 14:43 UTC

This package is auto-updated.

Last update: 2025-11-23 16:29:39 UTC


README

Latest Version Total Downloads Software License

A PHP parser for Strapi Rich Text fields

Usage

Get data from the Strapi API in StdClass format and pass it to the parser

use HugoLevet\StrapiPhpRichTextParser\RichTextParser;

$html_content = RichTextParser::jsonToHtml($content);

Using Shortcodes

You can add shortcodes like in WordPress by passing an array of shortcodes and their associated functions to the jsonToHtml function. For example:

$shortcodes = [
    'shortcode' => 'shortcodeFunction'
];

function shortcodeFunction($element)
{
    return 'Wubba Lubba Dub Dub';
}

$html = jsonToHtml($json, $shortcodes);
echo $html;

Environment variables

Make sure to set the environment variable STRAPI_URL with the URL of the Strapi API you are using

For development

To run the tests, use the following command:

./vendor/bin/phpunit tests