juststeveking/feed-parser 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

juststeveking/feed-parser

最新稳定版本:0.0.1

Composer 安装命令:

composer require juststeveking/feed-parser

包简介

A simple feed parser for PHP with zero dependencies.

README 文档

README

Latest Version PHP Version tests Total Downloads

A simple feed parser for PHP with zero dependencies.

Why

Most RSS and Atom parsers I have seen are either too complex or have too many dependencies. This is a simple feed parser that can parse both RSS and Atom feeds, with zero dependencies using a simple file_get_contents to fetch the feed itself.

Installation

composer require juststeveking/feed-generator

Usage

This package is designed to be super simple to use.

Parsing Atom Feeds

use JustSteveKing\FeedParser\AtomParser;
use JustSteveKing\FeedParser\FeedIterator;
use JustSteveKing\FeedParser\ValueObjects\AtomEntry;
use JustSteveKing\FeedParser\ValueObjects\AtomFeed;

$iterator = new FeedIterator(
    url: 'https://example.com/feed.atom',
    parser: new AtomParser(),
);

/** @var AtomFeed $item */
foreach ($iterator as $item) {
    echo $item->title(); // The Title of the Feed
    echo $item->link(); // The Link of the Feed
    echo $item->subtitle(); // The Subtitle of the Feed
    echo $item->updated(); // The Updated Date of the Feed
    echo $item->rights(); // The Rights of the Feed
    echo $item->generator(); // The Generator of the Feed

    /** @var AtomEntry $entry */
    foreach ($item->entries() as $entry) {
        echo $entry->title(); // The Title of the Entry
        echo $entry->link(); // The Link of the Entry
        echo $entry->id(); // The ID of the Entry
        echo $entry->updated(); // The Updated Date of the Entry
        echo $entry->summary(); // The Summary of the Entry
        echo $entry->content(); // The Content of the Entry
        echo $entry->author(); // The Author of the Entry
    }
}

Parsing RSS Feeds

use JustSteveKing\FeedParser\RssParser;
use JustSteveKing\FeedParser\FeedIterator;
use JustSteveKing\FeedParser\ValueObjects\RssChannel;
use JustSteveKing\FeedParser\ValueObjects\RssItem;

$iterator = new FeedIterator(
    url: 'https://example.com/feed.rss',
    parser: new RssParser(),
);

/** @var RssChannel $item */
foreach ($iterator as $item) {
    echo $item->title(); // The Title of the Feed
    echo $item->link(); // The Link of the Feed
    echo $item->description(); // The Description of the Feed

    /** @var RssItem $entry */
    foreach ($item->items() as $entry) {
        echo $entry->title(); // The Title of the Entry
        echo $entry->link(); // The Link of the Entry
        echo $entry->guid(); // The GUID of the Entry
        echo $entry->pubDate(); // The Published Date of the Entry
        echo $entry->description(); // The Description of the Entry
        echo $entry->author(); // The Author of the Entry
    }
}

Testing

You can run the tests using the following command:

composer test

Static Analysis

You can run PHPStan using the following command:

composer stan

Code Style

You can run Laravel Pint using the following command:

composer pint

Refactoring

You can run Rector using the following command:

composer refactor

Credits

LICENSE

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固