PHP code example of ahmed-aliraqi / laravel-rss

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

    

ahmed-aliraqi / laravel-rss example snippets


Route::get('/', function()
{
	$feed = Rss::feed('2.0', 'UTF-8');
	$feed->channel([
	    'title'       => "Channel's title",
	    'description' => "Channel's description",
	    'link'        => "http://www.test.com/"
    ]);
    
	for ($i=1; $i<=5; $i++) {
		$feed->item([
		    'title' => 'Item '.$i,
		    'description|cdata' => 'Description '.$i,
		    'link' => 'http://www.test.com/article-'.$i
	    ]);
	}

	return response($feed, 200)->header('Content-Type', 'text/xml');
});

Route::get('/', function()
{
	$feed = Rss::feed('2.0', 'UTF-8');
	$feed->channel([
	    'title'       => "Channel's title",
	    'description' => "Channel's description",
	    'link'        => "http://www.test.com/"
    ]);
    
	for ($i=1; $i<=5; $i++) {
		$feed->item([
		    'title' => 'Item '.$i,
		    'description|cdata' => 'Description '.$i,
		    'link' => 'http://www.test.com/article-'.$i
	    ]);
	}

	$feed->save('test.xml');
});