eko / feedbundle Goto Github PK
View Code? Open in Web Editor NEWA Symfony bundle to build RSS feeds from your entities
Home Page: http://vincent.composieux.fr
License: MIT License
A Symfony bundle to build RSS feeds from your entities
Home Page: http://vincent.composieux.fr
License: MIT License
Currently, it's not possible to use this bundle on the current https://github.com/symfony/symfony-standard edition because of the upper bound at https://github.com/eko/FeedBundle/blob/master/composer.json#L16
Do you think you could tag your bundle so that it will work? Cheers.
I was custom channel field in RSS but I can not find any where How I can add custom item field under custom channel field ?
Like this:
<image>
<url>www.xyz.com</url>
<title>XYZ</title>
<description>abcdefgh</description>
</image>
Any help !
Is there support for media items in feed reader?
Thanks
Hi,
I am trying to save the RSS feeds being fetched to my database, following the instructions this is the code inside my controller
$reader = $this->get('eko_feed.feed.reader'); $items = $reader->load('http://rss.indeed.com/rss?q=Singapore')->populate('AppBundle\Entity\Rss');
This is my Rss Entity
title = $title; } /** * Returns a description or content * * @return string */ public function setFeedItemDescription($description) { $this->description = $description; } /** * Returns item link * * @return string */ public function setFeedItemLink($link) { $this->link = $link; } /** * Returns publication date * * @return \DateTime */ public function setFeedItemPubDate(\DateTime $date) { $this->date = $date; } /** * Get title * * @return string */ public function getTitle() { return $this->title; } /** * Get description * * @return string */ public function getDescription() { return $this->description; } /** * Get link * * @return string */ public function getLink() { return $this->link; } /** * Get publication date * * @return \DateTime */ public function getPublicationDate() { return $this->date; } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set title * * @param string $title * @return Rss */ public function setTitle($title) { $this->title = $title; return $this; } /** * Set description * * @param string $description * @return Rss */ public function setDescription($description) { $this->description = $description; return $this; } /** * Set link * * @param string $link * @return Rss */ public function setLink($link) { $this->link = $link; return $this; } /** * Set date * * @param \DateTime $date * @return Rss */ public function setDate($date) { $this->date = $date; return $this; } /** * Get date * * @return \DateTime */ public function getDate() { return $this->date; } /** * Set publicationDate * * @param \DateTime $publicationDate * @return Rss */ public function setPublicationDate($publicationDate) { $this->publicationDate = $publicationDate; return $this; } /** * Get feedItemTitle * * @return string */ public function getFeedItemTitle() { return $this->feedItemTitle; } /** * Get feedItemDescription * * @return string */ public function getFeedItemDescription() { return $this->feedItemDescription; } /** * Get feedItemLink * * @return string */ public function getFeedItemLink() { return $this->feedItemLink; } /** * Get feedItemPubDate * * @return \DateTime */ public function getFeedItemPubDate() { return $this->feedItemPubDate; } }
When i run the action the error i get is as following and i don't understand why. What am i doing wrong?
Error: Call to a member function hydrate() on null
Hi
Is exists solution to avoid 'static' config, for example:
eko_feed:
feeds:
article:
title: 'My articles/posts'
description: 'Latests articles'
link: 'http://vincent.composieux.fr'
encoding: 'utf-8'
author: 'Vincent Composieux' # Only required for Atom feeds
and do it dynamically for each request?
Hi, would it be possible tag a new version whenever you can to get rid of the deprecations notices? Thanks
Could you add the bundle to Packagist ?
Thanks
I just tried to install symfony-cmf/cmf-sandbox that uses this bundle on ubuntu 12.04 lts. This is not possbile since zf 2.3 requires at least php 5.3.23
Would it make sense to limit the zend dependencies to 2.2?
/cc @dbu
Salut,
Pouvez-vous expliquer comment ajouter de nouveaux champs.
J'aimerai ajouter plusieurs élément "category" dans les éléments "item".
Merci.
Hy !
Can you add some explanation about the possibility of adding new field?
I want to add multiple field "category" into the "item" element.
Thanks
Hi, is there any possibility to configure dynamic route_params? e.g. I have the following use case:
URL: /order/12345/delivery (where 12345 represents an unique order number) should return the following ATOM feed:
`
<title>order/delivery-feed</title>
<subtitle>xxx</subtitle>
<link href="/order/12345/delivery" rel="self" type="application/rss+xml"/>
<updated>2016-09-05T09:45:25+02:00</updated>
<id>/order/12345/delivery</id>
<author>
<name>xxx</name>
</author>
The issue is, that in config.yml I can only configure static routing params, e.g
link:
route_name: order_delivery
route_params:
id: xyz
And this would result in
<link href="/order/xyz/delivery" rel="self" type="application/rss+xml"/>
Please tell me, how can I inject the order number 12345 into the feed itself?
BR
Daniel
I believe there is a bug in Formatter/Formatter.php - on line 300, where the value is supposed to be set for an attribute, $item->getFeedItemLink() is being used in place of the value:
$element->setAttribute($field->get('attribute_name'), $item->getFeedItemLink());
should be
$element->setAttribute($field->get('attribute_name'), $value);
In case I'm misunderstanding how it's supposed to work, I am setting up the item with attributes like this:
$feed->addItemField(new ItemField('media:thumbnail', 'getFeedImageThumbnail',
array('attribute' => true,'attribute_name' => 'url')
));
and expect an xml element like:
<media:thumbnail url="http://example.com/image.jpg"/>
Thanks again for your work here
Hello,
Since few days, I have this error :
mod_fcgid: stderr: PHP Catchable fatal error: Argument 1 passed to Eko\FeedBundle\Feed\Feed::addItemField() must be an instance of Eko\FeedBundle\Field\Item\ItemFieldInterface, instance of Eko\FeedBundle\Field\MediaItemField given
This is my controller :
public function feedAction()
{
$annonces = $this->getDoctrine()->getRepository('LgmAnnonceBundle:Annonce')->derniereAnnonce();
$feed = $this->get('eko_feed.feed.manager')->get('annonces');
$feed->addFromArray($annonces);
$feed->addItemField(new MediaItemField('getFeedMediaItem'));
$response = new Response($feed->render('atom'));
$response->headers->set('Content-Type', 'application/rss+xml');
return $response;
}
I don't understand where is the source of the problem...
I have the same configuration of documentation. If someone can help me!
Thanks,
Hi, I think the method getFeedItemLink for generating the entity url is not sufficient. The url should be generated through the router. For example I have field "slug" handled by Doctrine Extensions sluggable and it's just a key, not a complete entity url.
Hello,
In php 7 with symfony 4 I have messages "is abandoned" like that
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead.
Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead.
Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead.
Package zendframework/zend-servicemanager is abandoned, you should avoid using it. Use laminas/laminas-servicemanager instead.
Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
Can you fix it?
Note: I've not researched RSS too much, so I'm not sure if it's even valid, but currently there's no way to add, say, a copyright
, generator
, or language
field to the channel since title
, description
and link
are hard-coded in an array in the RSSFormatter
.
I need publish information in atom xml format,
this i need
https://developers.facebook.com/resources/dpa_product_catalog_sample_feed_atom.xml
can i add extra fields to atom feed ?
Are you kidding ? You really renamed my issue and removed my message ?
I know, this can be a bit tricky but I would love to have support of enclosure to add item image.
<enclosure
type="image/jpeg"
url="http://www.example.org/myimage.jpg"
length="1234" />
<link rel="enclosure"
type="image/jpeg"
title="My nice picture"
href="http://www.example.org/myimage.jpg"
length="1234" />
I looked at the Field
class and see that is not possible "Out of the box".
Did you have any idea or advice on how to implement this ?
Hi,
Thanks for the good work.
I didn't find the way to add the complete author tag within entries in an atom feed.
Something like:
<entry>
...
<author>
<name>author's name</name>
[<email>author's email</email>]
</author>
</entry>
Thanks in advance for your help.
with generated rss on the fly, pubDate order seem not to be respected
Want newest first and older after
Is there a way to override order with "on the fly" method ?
A command must be created to generated feed on disk and not at runtime.
According to w3c validator, the feed should contain the atom namespace.
here is the spec: http://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
So when i tried to validate my RSS generated Feed, it was validated because the Atom namespace is messing.
this the current rendering:
<rss version="2.0">
Instead of this, we need to get:
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
So, jusr add in the RssFormatter:
$root->setAttribute('xmlns:atom', "http://www.w3.org/2005/Atom");
and the feed channel section, add:
<atom:link href="http://example.com/feed.xml" rel="self" type="application/rss+xml" />
here we need to put the href of the feed as config variable.
Thank you !
Hi,
When outputting an atom feed, the summary elements do not get the type="html".
Thanks!
Hi,
I have a news article rss feed.
One news item has an array of multiple links, containing a title + url.
So I would like to add to my news item
<links>
<link>
<title>My title</title>
<url>My Url<url>
</link>
...
</links>
In my action I do this:
$news = $news_repo->getAllNews($locale);
$feedManager = $this->get('eko_feed.feed.manager');
$feed = $feedManager->get('news');
$feed->addFromArray($news);
I can add extra ItemFields and MediaItemFields.
But I don't know how I can add an array of multiple link objects containing title + url.
I have this in my entity:
public function getLinkItems()
{
$items = array();
foreach ($links as $link){
$title = $link->getTitle();
$url = $link->getUrl();
$items[] =
array(
new ItemField('url', $url),
new ItemField('title', $title),
);
}
return $items;
}
And this in my action, but of course this is not correct:
$feed->addItemField( new GroupItemField('links', 'getLinkItems') );
Is there a way to do this?
Thanks.
Specified feed 'paints' is not defined in your configuration.
In : config/packages/eko_feed.yml
eko_feed:
feeds:
paints:
title: 'My latest things'
description: 'Here are my latetst things'
link: 'https://whatever.com'
encoding: 'utf-8'
author: 'Myself'
(Tried with eko_feed.yaml filename too)
In the controller
#[Route('/feed.rss', name: 'app_feed')]
public function feed()
{
$realisations = $this->getDoctrine()->getRepository('App:Peinture')->findAll();
$feed = $this->feedManager->get('paints');
$feed->addFromArray($realisations);
return new Response($feed->render('rss')); // or 'atom'
}
Hi
I act according to the instructions for use from feed bundle, but I run command
php app/console eko:feed:dump --name=article --entity=YoutabsGeneralModelBundle:Article --filename=rss.xml --format=atom --orderBy=id --direction=DESC
I have a error :
[ErrorException]
Warning: fopen(): Filename cannot be empty in C:\projects\shafajoo\vendor\e
ko\feedbundle\Eko\FeedBundle\Command\FeedDumpCommand.php line 77
I don't know ?
Sometimes you can get an error when trying to request a feed using https.
[Zend\Http\Client\Adapter\Exception\RuntimeException]
Unable to enable crypto on TCP connection domain.tld: make sure the "sslca
file" or "sslcapath" option are properly set for the environment.
[ErrorException]
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Using ...
use Zend\Feed\Reader\Reader as ZendFeedReader;
use Zend\Http\Client as ZendHttpClient;
Controller / Command:
/** @var \Eko\FeedBundle\Feed\Reader $FeedReader */
$FeedReader = $this->getContainer()->get('eko_feed.feed.reader');
$httpClientOptions = array(
'adapter' => 'Zend\Http\Client\Adapter\Socket',
'persistent'=>false,
'sslverifypeer' => false,
'sslallowselfsigned' => true,
'sslusecontext'=>true,
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true,
'capture_peer_cert' => true,
),
'useragent' => 'Feed Reader',
);
ZendFeedReader::setHttpClient(new ZendHttpClient(null, $httpClientOptions));
/** @var \Zend\Feed\Reader\Feed\FeedInterface $Feed */
$Feed = $FeedReader->load('domain.tld/rss')->get();
As discussed in #28, since some Zend updates this Bundle needs PHP >= 5.3.23.
Though... As it's only needed for compatibility with latests Zend updates, how could I install this Bundle with my PHP 5.3.3 ?
Is the only solution cloning this Bundle ?
The last commit introduced the following error:
The file "command.xml" does not exist (in: [...]/vendor/eko/feedbundle/DependencyInjection/..
/Resources/config).
The call to that file was added by the last merge but the corresponding file was not. So you should either add the missing file or remove the call...
Hi, first thanks for this very useful bundle. I figured out how to add attributes to a custom ItemField, what I need to do now is take it a step further and nest other tags beneath that. For example, i can get my <foo bar="whatever">
tag like so:
$feed->addItemField(new ItemField('foo', 'getBar', array(
'attribute' => true,
'attribute_name' => 'bar',
));
But what I ultimately need is this, and don't see a way yet to add attributes to GroupItemFields:
<foo bar="whatever">
<baz>Something Else</baz>
<bop>Another Thing</bop>
<boop>And Another</boop>
</foo>
One suggestion would be an option to pass either a string or an instance of ItemField as the first parameter of GroupItemField::construct(). In the case of a string, the current behavior remains (a simple tag like <string>
is used for the parent tag), but if an ItemField object is passed, then IT gets used as the parent tag. This would solve my problem, and potentially others?
So in this case, the code would look something like:
$parent = new ItemField('foo', 'getBar', array(
'attribute' => true,
'attribute_name' => 'bar',
));
$feed->addGroupItemField($parent, array(
new ItemField('baz', 'getBaz'),
new ItemField('bop', 'getBop'),
new ItemField('boop', 'getBoop'),
));
Thoughts?
I need to serve a RSS feed of a multi-language site.
What about adding translator service?
Once dev-zend is merged into master, do you think it will become possible to tag a released version in the near future (like next month)?
we plan to tag stable releases of the cmf bundles in march, once symfony 2.2 became stable. the more dependencies provide tagged versions, the easier for us to model the dependencies.
My server has to use a proxy when reading feed.
Is it possible to configure the reader
to use a proxy?
Or do I have to/can I use a workaround? E.g. load the content of the feed via another library, put it into a file and use the $reader->($localFilePath)
?
It would be awesome to have a new version released that supports Symfony 6. Installing dev-master
can be error prone
and each service must be tagged so they can be collected into a dedicated pool.
When executing the command which uses the FeedDumpService the following error occurs:
[Symfony\Component\Debug\Exception\ContextErrorException] Catchable Fatal Error: Argument 2 passed to Eko\FeedBundle\Service\FeedDumpService::__construct() must be an instance of Doctrine\ORM\EntityManager, instance of Ehealth\DoctrineEncryptionBundle\ORM\EntityManagerDecorator given, calle d in /run/shm/ehealthsoa/cache/dev/appDevDebugProjectContainer.php on line 2535 and defined
This error can be resolved by changing the typehint for Doctrine to: EntityManagerInterface
in the FeedDumpService::__constructor();
Hope this helps.
This means that you'd configure it something like this:
eko_feed:
feeds:
post:
link:
type: route
route_name: acme_blog_main_index
route_params: {}
Of course it might vary, but the idea is that I don't have to hard-code a link URL or use a parameter, the latter of which I am currently doing:
eko_feed:
feeds:
post:
link: 'http://%acme_blog_hostname%/'
Hi, I was wondering if you have incorporated the ability to output the relations within the entities. For example, if i had a many to many relation in my article entity to tags, then the feed can output the tags array ? is this possible?
thanks ( and great bundle btw )
I not see code section in your source where you use zend components.
Hi @eko,
I am trying to use this bundle for jobboard where the bundle will be setup to fetch jobs based on rss. At present I can see and persist the following information to the database
- feed_item_title
- feed_item_description
- feed_item_link
- feed_item_pub_date
But I need more information like, city, country, etc.. (the rss feeds we will be fetching provide this information) so I have few questions
hydrator
?hydrator
I should be able to access the details i need (city, state and country), if this is true then how do I access it?For example inside DefaultHydrator
I can see that you are doing the following
$entity->setFeedItemTitle($entry->getTitle());
How do you know that you have access to $entry->getTitle()
because when I var_dump
$entry
all i see is as following
object(Zend\Feed\Reader\Entry\Rss)[263]
protected 'xpathQueryRdf' => string '//rss:item[1]' (length=13)
protected 'xpathQueryRss' => string '//item[1]' (length=9)
protected 'data' =>
array (size=1)
'type' => string 'rss-20' (length=6)
protected 'domDocument' =>
object(DOMDocument)[36]
protected 'entry' =>
object(DOMElement)[266]
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
protected 'extensions' =>
array (size=7)
'Slash\Entry' =>
object(Zend\Feed\Reader\Extension\Slash\Entry)[370]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
'WellFormedWeb\Entry' =>
object(Zend\Feed\Reader\Extension\WellFormedWeb\Entry)[376]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
'Thread\Entry' =>
object(Zend\Feed\Reader\Extension\Thread\Entry)[369]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
'Podcast\Entry' =>
object(Zend\Feed\Reader\Extension\Podcast\Entry)[372]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
'DublinCore\Entry' =>
object(Zend\Feed\Reader\Extension\DublinCore\Entry)[373]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
'Content\Entry' =>
object(Zend\Feed\Reader\Extension\Content\Entry)[374]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
'Atom\Entry' =>
object(Zend\Feed\Reader\Extension\Atom\Entry)[375]
protected 'data' =>
array (size=1)
...
protected 'domDocument' =>
object(DOMDocument)[36]
...
protected 'entry' =>
object(DOMElement)[266]
...
protected 'entryKey' => int 0
protected 'xpath' =>
object(DOMXPath)[265]
...
protected 'xpathPrefix' => string '//item[1]' (length=9)
I do not see any object here that gives access to title
, content
or link
and so on.
So a bottom line is how do I see what all elements I have that I can pass to my Entity?
I hope my question is clear :)
The way feed is generated is not good as the buffer is kept in memory and then flush to the client.
You should implement a streamed solution, so there is no buffer on the php side, and the TTFB will be better.
the feed methods should not be set inside an entity but in a proper XML feed service. And so the logic can be reuse to generate a sitemap too :)
php 7.4.11, symfony 5.1.7, eko dev-master
EkoFeedBundle stopped working after symfony update.
Installed according to your manual https://github.com/eko/FeedBundle#installation
php bin/console eko:feed:dump
There are no commands defined in the "eko:feed" namespace.
2020-10-28T15:05:19+03:00 [info] User Deprecated: Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.
2020-10-28T15:05:19+03:00 [info] User Deprecated: Not passing a connection provider as the first constructor argument is deprecated
At run php bin/console debug:container and php bin/console debug:autowiring EkoFeedBundle not found, it feels like resources are not available
Hi.
I would like to know if there is any way to add some content in an Item, without calling a method in the Entity.
On my code, each entity Article as a "modules" property, which is an Array Collection of differents set of other entities ( in order for the user to be able to build flexible content).
Basically, i would like to add content in an Item, the same way i can add content to the Channel with the following method :
$feed->addChannelField(new ChannelField('custom_name', 'custom_value'));
Thanks for reader me.
Ludo
How to define your own lastBuildDate?
Hi, thanks a lot for the bundle.
I need generate a rss feed with several entities, is it possible?
thanks a lot
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.