add unit testing and using Guzzle
Change log
- add unit testing.
- use Guzzle to request the RSS feed.
- fix the if statement logic.
Thank you for PR. What is the benefit to use the Guzzle instead of cURL?
- Using Guzzle to request the url easily and make the code readability.
- We don't need to add the if-statement to check the cURL extension because the Guzzle will check the extension automatically.
- Guzzle is an abstraction layer for HTTP transport which happens to use cURL where available.
- Guzzle simplifies things enormously, particularly when it comes to debugging.
I am +1 on this PR.
Ideally you should pass a PSR-7 compatible implementation and use it.
As @perter279k said Guzzle is a very good choice and I can add to the list the killer feature: middlewares
Interesting middlewares for this project can be
- Cache: Instead of your disk cache you can delegate it to a cache middleware (and use disk, redis, memcache, etc)
- Retry MIddleware: sometimes your feed gets overloaded and you get a temporary 5XX error, with a retry middleware you can configure to retry X times with a configurable interval.
@grunjol I have no experience with this. Can you please give an example code, how can be used middleware for cache or retry used?
Today I had to implement it for a project I am working on, so I rushed it and took @peter279k master (which this PR is based on) and forked the repo. I changed a little bit the interface (moved auth user/pass as options for the request) so, this will break the current API, but the good thing is I was able to create a working Cache (and a cloudflare busting mechanism)
Check it out https://github.com/grunjol/rss-php, I put some examples in the README file including a volatile (memory) cache, you can use any other cache backend (https://github.com/Kevinrob/guzzle-cache-middleware)
Thanks!
Any updates on this?
I don't receive any request changes for while.
I still wait for the response :).
@dg Can you merge this in?