Download the PHP package debril/feed-io without Composer
On this page you can find all versions of the php package debril/feed-io. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package feed-io
feed-io
feed-io is a PHP library built to consume and serve news feeds. It features:
- JSONFeed / Atom / RSS read and write support
- Feeds auto-discovery through HTML headers
- a Command line interface to discover and read feeds
- PSR-7 Response generation with accurate cache headers
- HTTP Headers support when reading feeds in order to save network traffic
- Detection of the format (RSS / Atom) when reading feeds
- Enclosure support to handle external medias like audio content
- Feed logo support (RSS + Atom)
- PSR compliant logging
- Content filtering to fetch only the newest items
- DateTime detection and conversion
- A generic HTTP ClientInterface
- Integrates with every PSR-18 compatible HTTP client.
This library is highly extensible and is designed to adapt to many situations, so if you don't find a solution through the documentation feel free to ask in the discussions.
Installation
Use Composer to add feed-io into your project's requirements :
Requirements
feed-io | PHP |
---|---|
4.x | 7.1+ |
5.0 | 8.0+ |
6.0 | 8.1+ |
feed-io 4 requires PHP 7.1+, feed-io 5 requires PHP 8.0+. All versions relies on psr/log
and any PSR-18 compliant HTTP client. To continue using you may require php-http/guzzle7-adapter
. it suggests monolog
for logging. Monolog is not the only library suitable to handle feed-io's logs, you can use any PSR/Log compliant library instead.
Usage
CLI
Let's suppose you installed feed-io using Composer, you can use its command line client to read feeds from your terminal :
reading
feed-io is designed to read feeds across the internet and to publish your own. Its main class is FeedIo :
If you need to get only the new items since the last time you've consumed the feed, use the result's getItemsSince()
method:
You can also mix several filters to exclude items according to your needs:
In order to save bandwidth, feed-io estimates the next time it will be relevant to read the feed and get new items from it.
feed-io calculates the next update time by first detecting if the feed was active in the last 7 days and if not we consider it as sleepy. The next update date for a sleepy feed is set to the next day at the same time. If the feed isn't sleepy we use the average interval and the median interval by adding those intervals to the feed's last modified date and compare the result to the current time. If the result is in the future, then it's returned as the next update time. If none of them are in the future, we considered the feed will be updated quite soon, so the next update time is one hour later from the moment of the calculation.
Please note: the fixed delays for sleepy and closed to be updated feeds can be set through Result::getNextUpdate()
arguments, see Result for more details.
Feeds discovery
A web page can refer to one or more feeds in its headers, feed-io provides a way to discover them :
Or you can use feed-io's command line :
You'll get all discovered feeds in the output.
formatting an object into a XML stream
Adding a StyleSheet
building a feed including medias
Creating a valid PSR-7 Response with a feed
You can turn a \FeedIo\FeedInstance
directly into a PSR-7 valid response using \FeedIo\FeedIo::getPsrResponse()
:
Building a FeedIo instance
To create a new FeedIo instance you only need to inject two dependencies :
- an HTTP Client implementing FeedIo\Adapter\ClientInterface. It can be wrapper for an external library like FeedIo\Adapter\Guzzle\Client
- a PSR-3 logger implementing Psr\Log\LoggerInterface
Another example with Monolog configured to write on the standard output :
Inject a custom Logger
You can inject any Logger you want as long as it implements Psr\Log\LoggerInterface
. Monolog does, but it's not the only library : https://packagist.org/providers/psr/log-implementation
Inject a custom HTTP Client
Since 6.0 there is a generic HTTP adapter that wraps any PST-18 compliant HTTP client.
Configure feed-io using the Factory
The factory has been deprecated in feed-io 5.2 and was removed in 6.0. Instantiate the facade directly and pass in the desired HTTP client and logger interface.
Dealing with missing timezones
Sometimes you have to consume feeds in which the timezone is missing from the dates. In some use-cases, you may need to specify the feed's timezone to get an accurate value, so feed-io offers a workaround for that :
Don't forget to reset feedTimezone
after fetching the result, or you'll end up with all feeds located in the same timezone.
Built with PHP Storm
Most of feed-io's code was written using PHP Storm courtesy of Jetbrains.
All versions of feed-io with dependencies
ext-dom Version *
ext-json Version *
ext-libxml Version *
guzzlehttp/guzzle Version ~6.2|~7.0
psr/log Version ~1.0|~2.0|~3.0