Laravel Packages

Export Large Amounts of Data into Feeds with the Feeds Package for Laravel

Published
Export Large Amounts of Data into Feeds with the Feeds Package for Laravel image

The Feeds package for Laravel by Andrey Helldar is an easy and fast way to export large amounts of data into feeds for marketplaces and other consumers. At the core of this package are feeds, which you can generate with the provided make:feed Artisan command. Once you create a feed, you can define how it works:

namespace App\Feeds;

use App\Feeds\Items\UserFeedItem;
use App\Models\User;
use DragonCode\LaravelFeed\Enums\FeedFormatEnum;
use DragonCode\LaravelFeed\Feeds\Feed;
use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class UserFeed extends Feed
{
    protected FeedFormatEnum $format = FeedFormatEnum::Json;

    public function builder(): Builder
    {
        return User::query()
            ->whereNotNull('email_verified_at')
            ->where('created_at', '>', now()->subYear());
    }

    public function item(Model $model): FeedItem
    {
        return new UserFeedItem($model);
    }
}

Along with the UserFeed class, is the UserFeedItem class, which defines each feed item:

namespace App\Feeds\Items;

use DragonCode\LaravelFeed\Feeds\Items\FeedItem;

/** @property-read \App\Models\User $model */
class UserFeedItem extends FeedItem
{
    public function toArray(): array
    {
        return [
            'name'  => $this->model->class,
            'email' => $this->model->email,
        ];
    }
}

These feeds are generated via the feed:generate command, which produces feeds in static files (stored in the public folder by default). The documentation includes recipes for common formats, such as XML sitemaps, RSS, and more.

Main Features

  • Chunked queries to the database
  • Draft mode during processing
  • Easy property mapping
  • Generate feeds, sitemaps, and more

💻 You can get started with this package on GitHub: TheDragonCode/laravel-feeds.

📖 To install and configure this package, read the package's documentation.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
Laravel Herd 2: Coding Agents, Workspaces, and Cloud Deploys image

Laravel Herd 2: Coding Agents, Workspaces, and Cloud Deploys

Read article
Strict Request Input Casting in Laravel image

Strict Request Input Casting in Laravel

Read article
Prevent Duplicate File Uploads With Laravel Storage Dedupler image

Prevent Duplicate File Uploads With Laravel Storage Dedupler

Read article
Slow Job Alerts and Replica Commit IDs in Laravel 13.40 image

Slow Job Alerts and Replica Commit IDs in Laravel 13.40

Read article
Flock: A Free, Native Herd Alternative for Laravel image

Flock: A Free, Native Herd Alternative for Laravel

Read article
Live Props for Real-Time Updates in Inertia.js v3.11 image

Live Props for Real-Time Updates in Inertia.js v3.11

Read article