{"id":26021208,"url":"https://github.com/teclone/php-feed-parser","last_synced_at":"2025-03-06T08:50:30.497Z","repository":{"id":38176823,"uuid":"145221192","full_name":"teclone/php-feed-parser","owner":"teclone","description":"A fully integrated RSS, ATOM and RDF syndication feed parser","archived":false,"fork":false,"pushed_at":"2022-12-10T22:23:29.000Z","size":1508,"stargazers_count":10,"open_issues_count":12,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-25T05:16:46.045Z","etag":null,"topics":["atom-feed-parser","feed-parser","rdf-feed-parser","rss-feed-parser","syndication","web-scraping"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teclone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-18T13:14:00.000Z","updated_at":"2024-01-22T07:24:21.000Z","dependencies_parsed_at":"2023-01-26T09:45:19.530Z","dependency_job_id":null,"html_url":"https://github.com/teclone/php-feed-parser","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fphp-feed-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fphp-feed-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fphp-feed-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fphp-feed-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teclone","download_url":"https://codeload.github.com/teclone/php-feed-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242179280,"owners_count":20084940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atom-feed-parser","feed-parser","rdf-feed-parser","rss-feed-parser","syndication","web-scraping"],"created_at":"2025-03-06T08:50:29.848Z","updated_at":"2025-03-06T08:50:30.486Z","avatar_url":"https://github.com/teclone.png","language":"PHP","readme":"# PHP Feed Parser\n\n[![Build Status](https://travis-ci.org/teclone/php-feed-parser.svg?branch=master)](https://travis-ci.org/teclone/php-feed-parser)\n[![Coverage Status](https://coveralls.io/repos/github/teclone/php-feed-parser/badge.svg?branch=master)](https://coveralls.io/github/teclone/php-feed-parser?branch=master)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n![Packagist](https://img.shields.io/packagist/dt/forensic/feed-parser.svg)\n\nPHP Feed Parser is a fully integrated web syndication feed parser. It can successfully parse all the three major syndication feeds which include [RSS](http://cyber.harvard.edu/rss/rss.html), [ATOM](https://tools.ietf.org/html/rfc4287) \u0026 [RDF](http://web.resource.org/rss/1.0/spec) feeds.\n\nIt produces clean, unified parse accross all the three supported feed types. It is configurable, lightweight, fully tested and allows one to parse feeds from three different sources that includes **parsing from url, from file or from string**.\n\n## Getting Started\n\n**Install via composer**:\n\n```bash\ncomposer require forensic/feed-parser\n```\n\nCreate an instance as shown below:\n\n```php\n//include composer autoload.php\nrequire 'vendor/autoload.php';\n\n//use the project's Parser module\nuse Forensic\\FeedParser\\Parser;\n\n//create an instance\n$parser = new Parser();\n\n//parse yahoo rss news feed\n$feed = $parser-\u003eparseFromURL('https://www.yahoo.com/news/rss/mostviewed');\n\n//access feed properties\necho $feed-\u003etype; //1 for RSS, 2 for ATOM, 3 for RDF\necho $feed-\u003etitle;\necho $feed-\u003elink;\necho $feed-\u003elastUpdated;\necho $feed-\u003egenerator;\necho $feed-\u003edescription;\necho $feed-\u003eimage-\u003esrc;\n....\n\n//access items\n$items = $feed-\u003eitems;\n\nforeach ($items as $item)\n{\n    //access feed item properties\n    echo $item-\u003elink;\n    echo $item-\u003econtent;\n    echo $item-\u003etextContent; // the same as content, but all html tags are stripped out\n    echo $item-\u003ecreatedAt;\n    echo $item-\u003elastUpdated;\n    echo $item-\u003ecategory;\n    echo $item-\u003eimage-\u003esrc;\n    echo $item-\u003eimage-\u003etitle;\n    .....\n}\n```\n\n## Export Feed as JSON\n\nYou can also export the parsed feed as json, as shown below. This can also help you view all properties that are accessible in the parsed feed.\n\n```php\n//create an instance\n$parser = new Parser();\n\n//parse yahoo rss news feed\n$feed = $parser-\u003eparseFromURL('https://www.yahoo.com/news/rss/mostviewed');\n\nheader('Content-Type: application/json');\n\n//export whole feed\necho $feed-\u003etoJSON();\n\n//export a single item\necho $feed-\u003eitems[0]-\u003etoJSON();\n```\n\n## Parser Options\n\nThe following configuration options can be passed in when creating an instance or set through the designated public methods:\n\n```php\n//constructor signature\nnew Parser(\n    string $default_lang = 'en',\n    bool $remove_styles = true,\n    bool $remove_scripts = true\n);\n```\n\n- **default_lang**:\n\n  This option sets the default feed language property to use should there be no language entry found in the xml document.\n\n  ```php\n  $parser = new Parser();\n  $parser-\u003esetDefaultLanguage('fr');\n  ```\n\n- **remove_styles**:\n\n  This option states if stylings found in any feed item's content, should be stripped off. The stylings include html `style` element and attribute. Defaults to true.\n\n  ```php\n  $parser = new Parser();\n  $parser-\u003eremoveStyles(true);\n  ```\n\n- **remove_scripts**:\n\n  This option states if any scripting found in any feed item's content, should be stripped off. Scripting includes html `script` element and event handler `on-prefixed` element attributes such as `onclick`. Defaults to true.\n\n  ```php\n  $parser = new Parser();\n  $parser-\u003eremoveScripts(true);\n  ```\n\n## Testing FeedParser\n\nTo locally test or contribute to this project, You should have at least php 7.1, xDebug, composer and npm installed, then ollow the steps below:\n\n**Clone this repo**:\n\n```bash\ngit clone https://github.com/teclone/php-feed-parser \u0026\u0026 php-feed-parser\n```\n\n**Install dependencies**:\n\n```bash\ncomposer install \u0026\u0026 npm install\n```\n\n**Run test**:\n\n```bash\nvendor/bin/phpunit\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteclone%2Fphp-feed-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteclone%2Fphp-feed-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteclone%2Fphp-feed-parser/lists"}