PHPackages                             tourze/rss-feed-collect-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/rss-feed-collect-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/rss-feed-collect-bundle
==============================

0.0.1(4mo ago)00MITPHPCI passing

Since Dec 19Pushed 4mo agoCompare

[ Source](https://github.com/tourze/rss-feed-collect-bundle)[ Packagist](https://packagist.org/packages/tourze/rss-feed-collect-bundle)[ RSS](/packages/tourze-rss-feed-collect-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (36)Versions (2)Used By (0)

RSS Feed Collect Bundle
=======================

[](#rss-feed-collect-bundle)

[English](README.md) | [中文](README.zh-CN.md)

RSS源抓取收集Bundle，提供定时抓取RSS源内容并存储到数据库的功能。

核心功能
----

[](#核心功能)

- **RSS源管理**: 支持多个RSS源的配置和管理
- **自动抓取**: 基于配置的间隔时间自动抓取RSS内容
- **智能去重**: 基于文章链接自动去重，避免重复存储
- **状态管理**: 跟踪每个RSS源的抓取状态和错误信息
- **Console命令**: 支持手动触发和批量抓取

快速开始
----

[](#快速开始)

### 1. 安装依赖

[](#1-安装依赖)

```
composer install
```

### 2. 运行数据迁移

[](#2-运行数据迁移)

```
php bin/console doctrine:migrations:migrate
```

### 3. 加载测试数据

[](#3-加载测试数据)

```
php bin/console doctrine:fixtures:load
```

### 4. 执行RSS抓取

[](#4-执行rss抓取)

```
# 抓取单个RSS源 (必须指定feed-id)
php bin/console rss:collect-feed --feed-id=1

# 强制抓取单个RSS源
php bin/console rss:collect-feed --feed-id=1 --force

# 抓取所有到期的RSS源
php bin/console rss:collect-feeds

# 强制抓取所有活跃RSS源
php bin/console rss:collect-feeds --force

# 查看统计信息
php bin/console rss:collect-feeds --stats
```

测试用RSS源
-------

[](#测试用rss源)

Bundle预置了百度科技新闻RSS源用于真实测试：

- **名称**: 百度-科技最新
- **URL**: [https://news.baidu.com/n?cmd=4&amp;class=technnews&amp;tn=rss](https://news.baidu.com/n?cmd=4&class=technnews&tn=rss)
- **抓取间隔**: 30分钟
- **用途**: 可发起真实HTTP请求进行功能验证

架构设计
----

[](#架构设计)

### 实体结构

[](#实体结构)

```
RssFeed (RSS源)
├── id: 主键
├── name: RSS源名称
├── url: RSS源URL地址
├── category: 分类
├── collectIntervalMinutes: 抓取间隔(分钟)
├── status: 状态(active/error/disabled)
├── lastCollectTime: 最后抓取时间
├── lastError: 最后错误信息
└── itemsCount: 文章总数

RssItem (RSS文章)
├── id: 主键
├── title: 文章标题
├── link: 文章链接 (去重键)
├── description: 文章描述
├── content: 文章内容
├── guid: 文章GUID
├── publishTime: 发布时间
└── rssFeed: 关联RSS源

```

### 服务层

[](#服务层)

- `RssFeedCollectService`: 核心抓取服务，处理HTTP请求、XML解析、数据存储
- `RssFeedRepository`: RSS源数据访问层
- `RssItemRepository`: RSS文章数据访问层

Console命令
---------

[](#console命令)

### rss:collect-feed

[](#rsscollect-feed)

单个RSS源抓取命令，专门处理指定RSS源的抓取。

```
# 抓取指定RSS源
php bin/console rss:collect-feed --feed-id=1

# 强制抓取（忽略抓取间隔）
php bin/console rss:collect-feed --feed-id=1 --force
```

### rss:collect-feeds

[](#rsscollect-feeds)

批量RSS源抓取命令，遍历所有RSS源并执行抓取。

```
# 抓取所有到期的RSS源
php bin/console rss:collect-feeds

# 强制抓取所有活跃RSS源
php bin/console rss:collect-feeds --force

# 查看统计信息
php bin/console rss:collect-feeds --stats
```

环境配置
----

[](#环境配置)

```
# RSS抓取超时时间(秒)，默认30
RSS_COLLECT_TIMEOUT=30

# RSS抓取User-Agent，默认"RSS Feed Collector Bot/1.0"
RSS_COLLECT_USER_AGENT="RSS Feed Collector Bot/1.0"
```

运行测试
----

[](#运行测试)

```
# 运行所有测试
./vendor/bin/phpunit

# 运行静态分析
php -d memory_limit=2G vendor/bin/phpstan analyse --level=8
```

使用示例
----

[](#使用示例)

### 添加新的RSS源

[](#添加新的rss源)

```
$rssFeed = new RssFeed();
$rssFeed->setName('技术博客');
$rssFeed->setUrl('https://example.com/feed.xml');
$rssFeed->setCategory('技术');
$rssFeed->setCollectIntervalMinutes(60);
$rssFeed->setIsActive(true);

$entityManager->persist($rssFeed);
$entityManager->flush();
```

### 手动抓取RSS源

[](#手动抓取rss源)

```
$collectService = $container->get(RssFeedCollectService::class);
$result = $collectService->collectFeed($rssFeed);

if ($result['success']) {
    echo "抓取成功，新增文章: " . $result['items_count'];
} else {
    echo "抓取失败: " . $result['error'];
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance74

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

142d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-rss-feed-collect-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-rss-feed-collect-bundle/health.svg)](https://phpackages.com/packages/tourze-rss-feed-collect-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
