PHP code example of cammanderson / mmb

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

    

cammanderson / mmb example snippets


...
$app->register(new MMB\ArticleServiceProvider());
...
// Controller
$articleController = function (Silex\Application $app, MMB\Article $article) {
    return $app['twig']->render('article.html.twig', array(
            'article' => $article,
            'highlighter' => $app['markdown_parser_highlighter']
        ));
};

// Add the article route
$app->get('/article/{article}', function (MMB\Article $article) use ($app, $articleController) {
    return $articleController($app, $article);
})->assert('article', '.+')
->convert('article', 'article_service:getArticle');
...

class MyArticleService extends AbstractArticleService
{
    public function getArticle($key)
    {
        // TODO: Implement your own method to locate the article
        $articleContents = '...';

        // Create the article
        $article = $this->provider->provide($key, $articleContents);

        // ... Apply further properties your Service supports

        // Return
        return $article;
    }
}

$app['article_service'] = $app->share(function ($app) {
    $service = new MyArticleService();
    $service->setProvider($app['article_provider']);
    return $service;
});