PHP code example of sergmoro1 / yii2-feed

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

    

sergmoro1 / yii2-feed example snippets


namespace frontend\controllers;

use Yii;
use yii\helpers\Url;
use yii\data\ActiveDataProvider;
use common\models\Post;

class RssController extends \sergmoro1\feed\controllers\RssController
{
    public function providers()
    {
        $providers = [];
        $providers['_view'] = new ActiveDataProvider([
            'query' => Post::find()->where([
                'status' => Post::STATUS_PUBLISHED
            ]),
            'sort' => [
                'defaultOrder' => [
                    'created_at' => SORT_DESC,
                ],
            ],
        ]);
        return $providers;
    }

    public function channel()
    {
        return [
            'title' => Yii::$app->name,
            'description' => 'Programmer\'s notes, code examples. WordPress, Yii.',
            'description' => 'Notes, code examples. Yii, WordPress.',
            'link' => Url::toRoute('/', true),
            'language' => Yii::$app->language,
            'image' => [
                'url' => Url::to('@web/logo/logo.png', true),
                'title' => Yii::$app->name,
                'link' => Url::to('@web/logo/logo.png', true),
            ],
            'ttl' => 60,
        ];
    }
}