PHP code example of 20minutes / php-draftjs-html

1. Go to this page and download the library: Download 20minutes/php-draftjs-html library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

20minutes / php-draftjs-html example snippets




namespace Tests;

use Willtj\PhpDraftjsHtml\Converter;
use Prezly\DraftPhp\Converter as DraftConverter;

// From a JSON string
$contentState = DraftConverter::convertFromJson($input);
$converter = new Converter;
$result = $converter
    ->setState($contentState)
    ->toHtml();

$converter->updateStyleMap(['BOLD' => ['element' => 'b']]);