PHP code example of tallieutallieu / dry-blog

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

    

tallieutallieu / dry-blog example snippets




$app = new \Oak\Application();

$app->register([
    \Tnt\Blog\BlogServiceProvider::class,
]);

$app->bootstrap();



class blog extends base
{
    public static function index(Request $request, Page $page)
    {
        $app = Application::get();

        $dataList = $app->getWith(DataListInterface::class, [
            'repository' => BlogPosts::published()->recent(),
            'urlBuilder' => $app->getWith(BuilderInterface::class, [
                'base' => \dry\url('pages::view', $page),
            ]),
        ]);
        
        $tpl = parent::get_base_template($request, $page);
        $tpl->blogPosts = $dataList->getResults();
        $tpl->render( 'blog/index.tpl' );
    }
}