Skip to main content
Version: 1.x

← Previous · Back to README · Next →

Supported formats

  • xml — Generates feeds in XML format.
  • json — Generates feeds in JSON format.
  • jsonl — Generates feeds in JSON Lines format.
  • csv — Generates feeds in CSV format.
  • rss — Generates feeds in RSS Atom format.

By default, the xml format is used.

Per-feed converter options​

Apply DragonCode\LaravelFeed\Attributes\Config to a feed class to override its converter settings:

use App\Models\User;
use DragonCode\LaravelFeed\Attributes\Config;
use DragonCode\LaravelFeed\Enums\FeedFormatEnum;
use DragonCode\LaravelFeed\Feeds\Feed;
use Illuminate\Database\Eloquent\Builder;

#[Config('delimiter', ',')]
#[Config('enclosure', "'")]
#[Config('lineEnding', "\r\n")]
class UserFeed extends Feed
{
protected FeedFormatEnum $format = FeedFormatEnum::Csv;

public function builder(): Builder
{
return User::query();
}
}

Repeat the attribute for each setting. If a name is repeated on the same class, the last declared attribute wins.

Setting names are converter constructor parameter names. Only supplied values override the application configuration; other settings keep their configured values. lineEnding corresponds to feeds.converters.csv.line_ending.

FormatSupported keys
csvdelimiter, enclosure, escape, lineEnding
jsonoptions, pretty
jsonloptions
xml, rsspretty

Parent feed options are inherited, and child keys override parent keys. Use only keys supported by the selected format; unsupported keys throw InvalidArgumentException. The attribute does not change the application configuration or other feeds.

JSON Lines always writes one item per line, and JSON_PRETTY_PRINT is removed from options. Custom container bindings must honor the supplied constructor parameters.

A custom DragonCode\LaravelFeed\Helpers\ConverterHelper that overrides get() or resolve() must also override the protected resolveWithOptions(FeedFormatEnum $format, array $options = []): Converter hook to use per-feed options. Pass $options to Container::make() so settings apply before the converter is initialized. Otherwise, resolving a feed with options throws LogicException; feeds without options retain the legacy helper behavior.

See Also​