PHP code example of marphy / blogstudio-bundle

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

    

marphy / blogstudio-bundle example snippets


use Marphy\BlogStudioBundle\Client\BlogStudioClientInterface;

class BlogController extends AbstractController
{
    #[Route('/blog', name: 'blog_index')]
    public function index(BlogStudioClientInterface $client): Response
    {
        $articles = $client->getArticles(limit: 10);

        return $this->render('blog/index.html.twig', [
            'articles' => $articles->articles,
            'nextCursor' => $articles->nextCursor,
        ]);
    }

    #[Route('/blog/{slug}', name: 'blog_show')]
    public function show(string $slug, BlogStudioClientInterface $client): Response
    {
        $article = $client->getArticle($slug);

        return $this->render('blog/show.html.twig', [
            'article' => $article,
        ]);
    }
}
bash
php bin/console blogstudio:test