Proposal idea: Feed Parser Interfaces

45 views
Skip to first unread message

Gabriel Solomon

unread,
Mar 1, 2019, 4:51:25 AM3/1/19
to PHP Framework Interoperability Group
Hi there PHP-FIG comunity!

I hope that my search of this topic has been successful and i have not missed if this topic has been discussed before.

I was wondering what would you think about a standard for Feed Parser libraries. 
I think that most of them follow the same path, but there are some small differences that might get aligned if there is a standard.

Bellow i have put a few lines of code of what it might look like

interface FeedInterface extends Iterator, Countable
{
    /**
     * Get a single author
     *
     * @param  int $index
     * @return string|null
     */
    public function getAuthor($index = 0);

    /**
     * Get an array with feed authors
     *
     * @return array
     */
    public function getAuthors();

    /**
     * Get the copyright entry
     *
     * @return string|null
     */
    public function getCopyright();

    /**
     * Get the feed creation date
     *
     * @return \DateTime|null
     */
    public function getDateCreated();

    /**
     * Get the feed modification date
     *
     * @return \DateTime|null
     */
    public function getDateModified();

    /**
     * Get the feed description
     *
     * @return string|null
     */
    public function getDescription();

    /**
     * Get the feed ID
     *
     * @return string|null
     */
    public function getId();

    /**
     * Get the feed language
     *
     * @return string|null
     */
    public function getLanguage();

    /**
     * Get a link to the HTML source
     *
     * @return string|null
     */
    public function getLink();

    /**
     * Get a link to the XML feed
     *
     * @return string|null
     */
    public function getFeedLink();

    /**
     * Get the feed title
     *
     * @return string|null
     */
    public function getTitle();
}

interface EntryInterface
{
    /**
     * Get the specified author
     *
     * @param  int $index
     * @return string|null
     */
    public function getAuthor($index = 0);

    /**
     * Get an array with feed authors
     *
     * @return array
     */
    public function getAuthors();

    /**
     * Get the entry content
     *
     * @return string
     */
    public function getContent();

    /**
     * Get the entry creation date
     *
     * @return \DateTime
     */
    public function getDateCreated();

    /**
     * Get the entry modification date
     *
     * @return \DateTime
     */
    public function getDateModified();
}


Alexander Makarov

unread,
Mar 1, 2019, 5:54:20 AM3/1/19
to PHP Framework Interoperability Group
Hello Gabriel,

Thanks for proposal but overall it doesn't sound like Feed Parsing is common enough task and that there's a need for parsers to be inter-operable.

If you have examples of different parsers and the need to exchange them or build re-usable components around them, feel free to discuss.

Gabriel Solomon

unread,
Mar 7, 2019, 2:13:52 PM3/7/19
to PHP Framework Interoperability Group
Hello Alexander,

Thank you for your response!
You are correct that Feed Parsing is not such a common module in php applications. 
The need definitely originated from a personal experience where i had 2 apps using a library that i had to change to another.

I would say that an objective argument would be that there is a stable specification for RSS structure.
Reply all
Reply to author
Forward
0 new messages