- How do I install feed-io in a Laravel project?
- Use Composer to install the package with `composer require php-feed-io/feed-io`. Ensure your Laravel app meets the PHP version requirements (8.1+ for v6.x). The package integrates seamlessly with Laravel’s service container and PSR-18 HTTP clients like Guzzle.
- Does feed-io support Laravel’s HTTP client for fetching remote feeds?
- Yes, feed-io works with Laravel’s HTTP facade (`Http::get()`) or any PSR-18 client. Use `Http::get($url)->toFeed()` for parsing remote feeds. For custom headers or timeouts, chain Laravel’s HTTP client methods before conversion.
- Can I generate RSS/Atom feeds dynamically in Laravel using this package?
- Absolutely. Use the `FeedIo` class to create feeds programmatically. For example, generate an Atom feed from a Laravel collection: `$feed = new FeedIo(); $feed->setTitle('My Blog')->addItems($postsCollection)->toAtom()`. Queue the job for background processing if needed.
- What Laravel versions does feed-io officially support?
- feed-io has no Laravel-specific dependencies, so it works with Laravel 8.x, 9.x, and 10.x. Test thoroughly with your Laravel version, as the package relies on PHP 8.1+ features. No breaking changes are expected for Laravel’s core functionality.
- How do I handle large feeds efficiently in Laravel?
- For large feeds, use `setLimit($limit)` to restrict the number of items parsed. Offload feed generation to Laravel queues (e.g., `FeedGenerateJob`) and cache parsed feeds in Redis or Memcached. Avoid loading entire feeds into memory at once.
- Are there any breaking changes in the latest version (v6.4.0) for Laravel users?
- No breaking changes exist for Laravel users in v6.4.0. However, underlying Guzzle dependencies (v7.12.1) may introduce HTTP handling edge cases. Test feed fetching with custom headers, timeouts, or proxies to ensure compatibility.
- Can I use feed-io to parse feeds from a Blade template?
- Yes, but parsing feeds in Blade is not recommended for performance reasons. Instead, fetch and parse feeds in a controller or service, then pass the results to Blade. Use Laravel Collections to transform feed data into a Blade-friendly format.
- How do I validate feed content before publishing in Laravel?
- Use Laravel’s built-in `Validator` to sanitize feed content before generation. For example, validate titles, descriptions, and URLs with rules like `['title' => 'required|string|max:255']`. feed-io’s validation is format-specific but can be extended with custom logic.
- What alternatives exist for RSS/Atom feed handling in Laravel?
- Alternatives include `spatie/feed` (simpler, Laravel-focused) or `simplepie` (legacy but widely used). Choose `spatie/feed` for minimalism or `simplepie` for legacy RSS support. feed-io stands out for JSONFeed, Atom/RSS dual support, and PSR compliance.
- How do I debug feed parsing errors in Laravel?
- Enable PSR-3 logging (e.g., Monolog) to capture feed-io errors. Use `try-catch` blocks around feed operations and log exceptions. For malformed feeds, implement custom error handlers or use `FeedIo::setLogger()` to route logs to Laravel’s logging channels.