PHP code example of diazoxide / yii2-blog

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

    

diazoxide / yii2-blog example snippets


 'modules'=>[
     'blog' => [
         'class' => "diazoxide\blog\Module",
         'urlManager' => 'urlManager',
         'imgFilePath' => dirname(__DIR__) . '/public/uploads/img/blog/',
         'imgFileUrl' => '/uploads/img/blog/',
         // You can change any view file for each route
         'frontendViewsMap'=>[
             'blog/default/index'=>'@app/views/blog/index'
         ],
         // You can change any layout for each route
         'frontendLayoutMap'=>[
             'blog/default/view'=>'@app/views/layouts/main-with-two-sidebar',
             'blog/default/archive'=>'@app/views/layouts/main-with-right-sidebar',
         ],
         'homeTitle'=>'Blog title',
         'userModel' => "\app\models\User",
         'userPK' => 'id',
         'userName' => 'username',
         'showClicksInPost'=>false,
         'enableShareButtons' => true,
         'blogPostPageCount' => '10',
         'schemaOrg' => [
             'publisher' => [
                 'logo' => '/path/to/logo.png',
                 'logoWidth' => 200,
                 'logoHeight' => 47,
                 'name' => "Blog title",
                 'phone' => '+1 800 488 80 85',
                 'address' => 'Address 13/5'
             ]
         ]
     ],
 ]

$config['modules']['blog']['controllerNamespace'] = 'diazoxide\blog\controllers\backend';

 'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        //F.E. https://blog.com/category/politics
        '/category/<slug>' => '/blog/default/archive',
        
        //F.E. https://blog.com/archive
        '/archive' => '/blog/default/archive',
        
        //F.E. https://blog.com/2019/11/21/your-post-slug
        [
            'pattern' => '<year:\d{4}>/<month:\d{2}>/<day:\d{2}>/<slug>',
            'route' => '/blog/default/view',
            'suffix' => '/'
        ],
    ],
],

echo Nav::widget([
    'encodeLabels' => false,
    'options' => ['class' => $class],
    'items' => Yii::$app->getModule('blog')->getNavigation()
]);

'frontendViewsMap' => [
     'blog/default/index'=>'@app/views/blog/index',
     'blog/default/index' => 'index',
     'blog/default/view' => 'view',
     'blog/default/archive' => 'archive',
     'blog/default/book' => 'viewBook',
     'blog/default/chapter' => 'viewChapter',
     'blog/default/chapter-search' => 'searchBookChapter',
],

'frontendLayoutMap'=>[
    'blog/default/view'=>'@app/views/layouts/my-custom-layout-1',
    'blog/default/archive'=>'@app/views/layouts/my-custom-layout-2',
    ...
],
bash
php yii migrate --migrationPath=@vendor/diazoxide/yii2-blog/migrations