PHP code example of laravelium / feed

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

    

laravelium / feed example snippets


// config/app.php
'providers' => [
    // ...existing code...
    Rumenx\Feed\FeedServiceProvider::class,
],

use Rumenx\Feed\Feed;

public function feed(Feed $feed)
{
    $feed->setTitle('My Blog Feed');
    $feed->addItem([
        'title' => 'First Post',
        'author' => 'Rumen',
        'link' => 'https://example.com/post/1',
        'pubdate' => now(),
        'description' => 'This is the first post.'
    ]);
    return $feed->render('rss');
}

use Rumenx\Feed\Feed;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class FeedController extends AbstractController
{
    public function feed(Feed $feed)
    {
        $feed->setTitle('My Blog Feed');
        $feed->addItem([
            'title' => 'First Post',
            'author' => 'Rumen',
            'link' => 'https://example.com/post/1',
            'pubdate' => new \DateTime(),
            'description' => 'This is the first post.'
        ]);
        return $feed->render('atom');
    }
}

use Rumenx\Feed\Feed;

$feed = new Feed([
    'cache' => new MyCacheAdapter(),
    'config' => new MyConfigAdapter(),
    'response' => new MyResponseAdapter(),
    'view' => new MyViewAdapter(),
]);

$feed->setTitle('My Feed');
$feed->addItem([
    'title' => 'Hello',
    'author' => 'Rumen',
    'link' => 'https://example.com/hello',
    'pubdate' => date('c'),
    'description' => 'Hello world!'
]);
echo $feed->render('rss');
bash
composer 
bash
php artisan vendor:publish --provider="Rumenx\Feed\FeedServiceProvider"