PHP code example of knplabs / knp-markdown-bundle

1. Go to this page and download the library: Download knplabs/knp-markdown-bundle 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/ */

    

knplabs / knp-markdown-bundle example snippets


use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;

// from inside a controller
public function index(MarkdownParserInterface $parser)
{
    $html = $parser->transformMarkdown($text);
}

// or from inside a service
private $parser;

public function __construct(MarkdownParserInterface $parser)
{
    $this->parser = $parser;
}

public function someMethod()
{
    $html = $this->parser->transformMarkdown($text);
}