1. Go to this page and download the library: Download muspi/feedbundle 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/ */
muspi / feedbundle example snippets
public function registerBundles()
{
$bundles = array(
...
new Eko\FeedBundle\EkoFeedBundle(),
);
...
return $bundles;
}
namespace Bundle\BlogBundle\Entity;
use Eko\FeedBundle\Item\Writer\ItemInterface;
/**
* Bundle\BlogBundle\Entity\Article
*/
class Article implements ItemInterface
{
namespace Bundle\BlogBundle\Entity;
use Eko\FeedBundle\Item\Writer\RoutedItemInterface;
/**
* Bundle\BlogBundle\Entity\Article
*/
class Article implements RoutedItemInterface
{
namespace Bundle\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class BlogController extends Controller
{
/**
* Generate the article feed
*
* @return Response XML Feed
*/
public function feedAction()
{
$articles = $this->getDoctrine()->getRepository('BundleBlogBundle:Article')->findAll();
$feed = $this->get('eko_feed.feed.manager')->get('article');
$feed->addFromArray($articles);
return new Response($feed->render('rss')); // or 'atom'
}
}
$feed = $this->get('eko_feed.feed.manager')->get('article');
$feed->add(new FakeEntity());
$feed->addItemField(
new GroupItemField(
'categories',
new ItemField('category', 'getFeedCategoriesCustom', array(), array('category-attribute', 'test'),
array('categories-attribute', 'getAttributeValue')
)
);
$feed->addItemField(
new GroupItemField('author', array(
new ItemField('name', 'getFeedItemAuthorName', array('cdata' => true)),
new ItemField('email', 'getFeedItemAuthorEmail')
)
);
$feed->addChannelField(
new GroupChannelField('author', array(
new ChannelField('name', 'My author name'),
new ChannelField('email', '[email protected]')
)
);
/**
* Returns a custom media field
*
* @return string
*/
public function getFeedMediaItem()
{
return array(
'type' => 'image/jpeg',
'length' => 500,
'value' => 'http://website.com/image.jpg'
);
}
$feedDumpService = $this->get('eko_feed.feed.dump');
$feedDumpService
->setName($name)
//You can set an entity
//->setEntity($entity)
// Or set you Items
->setItems($MyOwnItemList)
->setFilename($filename)
->setFormat($format)
->setLimit($limit)
->setDirection($direction)
->setOrderBy($orderBy)
;
$feedDumpService->dump();