百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

php-feed

> 后端框架
开源

适用于 Laravel、Symfony 和任何 PHP 项目的框架无关的 PHP 订阅源生成器。生成具有全面缓存支持和可自定义视图的 RSS 和 Atom 订阅源。

364 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

适用于 Laravel、Symfony 和任何 PHP 项目的框架无关的 PHP 订阅源生成器。生成具有全面缓存支持和可自定义视图的 RSS 和 Atom 订阅源。

PHP Feed (Framework-Agnostic)

A modern, framework-agnostic PHP Feed generator for Laravel, Symfony, and any PHP project. Generate RSS and Atom feeds with full caching support and customizable views.

Features

  • Framework Agnostic: Works with Laravel, Symfony, or any PHP project
  • Multiple Formats: RSS 2.0 and Atom 1.0 support
  • ⚡ Caching: Built-in caching support with framework adapters
  • Custom Views: Use your own templates for feed generation
  • Dependency Injection: Clean architecture with adapter pattern
  • ✅ 100% Test Coverage: Thoroughly tested with Pest
  • PSR-12 Compliant: Follows modern PHP standards
  • Type Safe: Full PHP 8.3+ type declarations

Requirements

  • PHP 8.3+
  • Composer

Installation

bash
composer require rumenx/php-feed

Usage Examples

Laravel

Basic Usage:

…

Using Laravel Views (Optional):

For more control, you can use the included Blade templates:

…

Symfony

Basic Usage:

…

Using Symfony Views (Optional):

For more control, you can use Twig templates:

…

Plain PHP / Other Frameworks

Simple Usage (Recommended):

php
require 'vendor/autoload.php';

use Rumenx\Feed\FeedFactory;

// Create feed with simple built-in adapters
$feed = FeedFactory::create();
$feed->setTitle('My Feed');
$feed->setDescription('Feed description');
$feed->setLink('https://example.com');

$feed->addItem([
    'title' => 'Hello World',
    'author' => 'Rumen',
    'link' => 'https://example.com/hello',
    'pubdate' => date('c'),
    'description' => 'Hello world post!'
]);

// Output RSS feed
header('Content-Type: application/xml');
echo $feed->render('rss');

Advanced - Custom Adapters:

You can provide your own implementations for cache, config, response, and view:

php
use Rumenx\Feed\Feed;

$feed = new Feed([
    'cache' => new MyCacheAdapter(),
    'config' => new MyConfigAdapter(),
    'response' => new MyResponseAdapter(),
    'view' => new MyViewAdapter(),
]);

$feed->setTitle('My Feed');
$feed->addItem([
    'title' => 'Hello',
    'author' => 'Rumen',
    'link' => 'https://example.com/hello',
    'pubdate' => date('c'),
    'description' => 'Hello world!'
]);

// Use render() for framework-specific response
// or render() for XML string in plain PHP
echo $feed->render('rss');

Development

Available Composer Scripts

bash
# Run tests
composer test

# Run tests with coverage
composer test:coverage

# Run tests with HTML coverage report
composer test:coverage-html

# Watch tests (automatically re-run on file changes)
composer test:watch

# Static analysis with PHPStan
composer analyse

# Check code style (PSR-12)
composer style

# Fix code style automatically
composer style:fix

# Run all checks (tests + analysis + style)
composer check

# Run CI checks (coverage + analysis + style)
composer ci

API Reference

Factory Method

php
// Create feed with simple adapters (recommended for most users)
$feed = FeedFactory::create($config);

Core Methods

php
// Feed configuration
$feed->setTitle(string $title): self
$feed->setDescription(string $description): self
$feed->setLink(string $link): self
$feed->setDateFormat(string $format): self
$feed->setLanguage(string $language): self

// Item management
$feed->addItem(array $item): self
$feed->addItems(array $items): self

// Rendering
$feed->render(string $format = 'rss'): mixed // Returns framework-specific response or XML string

// Caching
$feed->isCached(string $key): bool
$feed->clearCache(string $key): self

Architecture

This package follows a clean architecture pattern with dependency injection:

  • Feed: Core feed generator class
  • Adapters: Framework-specific implementations
    • FeedCacheInterface: Caching operations
    • FeedConfigInterface: Configuration access
    • FeedResponseInterface: HTTP response handling
    • FeedViewInterface: Template rendering

Support This Project

If you find this project useful, please consider supporting its development: Other ways to support:

  • ⭐ Star this repository
  • Report bugs and suggest improvements
  • Contribute code or documentation
  • Make a donation - See FUNDING.md for details

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Security

If you discover any security-related issues, please check our Security Policy.

License

This package is open-sourced software licensed under the MIT License.

Links

  • Contributing Guidelines
  • Security Policy
  • License
  • Changelog
  • Funding & Support
  • Issues
  • GitHub Sponsors

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPatomcomposerfeedlaravel

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架