https://github.com/compolomus/rssreader
https://github.com/compolomus/rssreader
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/compolomus/rssreader
- Owner: Compolomus
- License: mit
- Created: 2022-06-19T15:04:02.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-28T15:59:17.000Z (about 2 years ago)
- Last Synced: 2025-02-19T06:13:27.956Z (over 1 year ago)
- Language: PHP
- Size: 40 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# RssReader by Compolomus
[](https://packagist.org/packages/compolomus/RssReader)
[](https://scrutinizer-ci.com/g/Compolomus/RssReader/build-status/master)
[](https://scrutinizer-ci.com/g/Compolomus/RssReader/?branch=master)
[](https://scrutinizer-ci.com/g/Compolomus/RssReader/?branch=master)
[](https://codeclimate.com/github/Compolomus/RssReader)
[](https://packagist.org/packages/compolomus/RssReader)
Small library for obtaining RSS feed with caching.
```shell
composer require compolomus/RssReader
```
## Usage
You can parse feed from multiple sources at once, and obtained posts will be sorted by timestamp (asc). Here's an example of how to use the `RssReader` class:
**Example**: Parsing RSS feeds and retrieving all posts
```php
getAll();
print_r($result);
```
After the first call of this script, you will see all messages from the RSS
feed with their IDs cached. On subsequent calls, only new IDs will be
processed because all cached IDs will be skipped. Each call will append IDs
to the cache, ensuring that you never receive duplicates from the feed.
**Advanced example**: Same as above but with customizing cache settings
```php
getAll();
print_r($result);
```
## Environment Variables
The `RssReader` library supports several environment variables for customization:
| Name | Default value | Description |
|----------------------|---------------------------------------|--------------------------------------------|
| RSSREADER_LIMIT | 0 _(0, empty or not set - unlimited)_ | Limiting the number of recent posts |
| RSSREADER_CACHE_DIR | /tmp/.rssreader_cache | Path to directory with cache |
| RSSREADER_CACHE_FILE | cacheIds.txt | Name of file in which cache will be stored |
Environment variable `RSSREADER_LIMIT` allows limiting the number of recent posts.
By default, there is no limit (0 or empty). The cache directory and filename
can also be customized using the `RSSREADER_CACHE_DIR` and `RSSREADER_CACHE_FILE`
environment variables.
## Testing
To run tests for this library, execute the following command:
```shell
composer test
```
## Quality Assurance
This project uses several tools to ensure code quality and maintainability:
* PHP_CodeSniffer: Checks the code syntax and style against the PSR-12 standard.
* PHPStan: Performs static analysis of the codebase to find potential bugs and errors.
* PHPUnit: Used for testing purposes.