rss-php icon indicating copy to clipboard operation
rss-php copied to clipboard

add unit testing and using Guzzle

Open peter279k opened this issue 9 years ago • 9 comments

Change log

  • add unit testing.
  • use Guzzle to request the RSS feed.
  • fix the if statement logic.

peter279k avatar Oct 16 '16 06:10 peter279k

Thank you for PR. What is the benefit to use the Guzzle instead of cURL?

dg avatar Oct 17 '16 11:10 dg

  1. Using Guzzle to request the url easily and make the code readability.
  2. We don't need to add the if-statement to check the cURL extension because the Guzzle will check the extension automatically.
  3. Guzzle is an abstraction layer for HTTP transport which happens to use cURL where available.
  4. Guzzle simplifies things enormously, particularly when it comes to debugging.

peter279k avatar Oct 17 '16 11:10 peter279k

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 avatar Mar 06 '17 18:03 grunjol

@grunjol I have no experience with this. Can you please give an example code, how can be used middleware for cache or retry used?

dg avatar Mar 06 '17 20:03 dg

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)

grunjol avatar Mar 06 '17 23:03 grunjol

Thanks!

dg avatar Mar 06 '17 23:03 dg

Any updates on this?

m1guelpf avatar Apr 20 '19 12:04 m1guelpf

I don't receive any request changes for while.

I still wait for the response :).

peter279k avatar Apr 20 '19 13:04 peter279k

@dg Can you merge this in?

m1guelpf avatar Apr 20 '19 20:04 m1guelpf