PHP code example of ivanamat / cakephp3-markdown

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

    

ivanamat / cakephp3-markdown example snippets


    class MyController extends AppController {

        public function initialize() {
            parent::initialize();

            $this->loadComponent('Markdown.Markdown');
        }

    }

    class MyController extends AppController {

        public $components = [
            'Markdown' => [
                'className' => 'Markdown.Markdown'
            ]
        ];

    }

    class AppView extends View {

        public function initialize() {
            parent::initialize();

            $this->loadHelper('Markdown.Markdown');
        }

    }

    # MyController

    $md = file_get_contents('../README.md', true);
    $html = $this->Markdown->parse($md);
    $this->set(compact('html'));

    # MyController

    $md = '`This` string `is an example` of **Markdown** code';
    $this->set(compact('md'));
ctp
    <!-- My view.ctp -->

     echo $this->Markdown->parse($md);