PHP code example of matks / markdown-blog-bundle

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

    

matks / markdown-blog-bundle example snippets



    // app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \Matks\MarkdownBlogBundle\MarkdownBlogBundle(),
        )
    }


$library = $this->get('markdown_blog.library');

/** @var Post[] $allPosts */
$allPosts = $library->getAllPosts();

/** @var boolean $isPostRegistered */
$isPostRegistered = $library->isPostRegistered();

/** @var Post $post */
$post = $library->getPostByName();

/** @var Post[] $posts */
$posts = $library->getPostsByName();

/** @var Post[] $posts */
$posts = $library->getPostsByDate();

/** @var Post[] $posts */
$posts = $library->getPostsByCategory();

/** @var Post[] $posts */
$posts = $library->getPostsByTag();




namespace AppBundle\Controller;

use Matks\MarkdownBlogBundle\Blog\Library;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class BlogController extends Controller
{
    public function indexAction(Request $request)
    {
        $library = $this->getLibrary();
        $allPosts = $library->getAllPosts();

        return $this->render(
            'default/index.html.twig',
            ['posts' => $allPosts]
        );
    }

    /**
     * @return Library
     */
    private function getLibrary()
    {
        return $this->get('markdown_blog.library');
    }
}