itmosoft / laravel-product-feeds
Product feed generation for Laravel applications, with configurable fields, CSV, XML and JSON exports, secure feed URLs, and scheduled regeneration hooks.
Requires
- php: ^8.3
- illuminate/contracts: ^12.0|^13.0
- illuminate/filesystem: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/routing: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^11.5|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Generate reusable product feeds for external channels and integrations using CSV, XML, or JSON.
Requirements
- PHP 8.3+
- Laravel 12 or 13
- PHP XMLWriter extension for XML output
Installation
composer require itmosoft/laravel-product-feeds php artisan vendor:publish --tag=product-feeds-config php artisan migrate
Laravel package discovery registers the service provider automatically.
Create a feed
A feed stores a mapping from output field names to product attribute paths. The plaintext token is returned only once when creating the feed; only its SHA-256 hash is stored.
use ItmoSoft\ProductFeeds\Models\ProductFeed; [$feed, $plainToken] = ProductFeed::createWithToken([ 'name' => 'Google Merchant Feed', 'format' => 'xml', 'fields' => [ 'id' => 'id', 'title' => 'name', 'description' => 'description', 'price' => 'price', 'availability' => 'stock_status', 'image_link' => 'primary_image_url', ], 'filters' => [ ['field' => 'price', 'operator' => 'greater_than', 'value' => 0], ['field' => 'availability', 'operator' => 'not_null'], ], ]); // Store $plainToken securely. It cannot be retrieved later.
Generate a feed
Pass an iterable of arrays, objects, or Eloquent models. The package does not assume a specific product-catalog package or product model.
$products = Product::query() ->where('is_active', true) ->cursor(); $feed->generate($products);
The generated file is saved to the configured filesystem disk under
product-feeds/{feed-id}.{format} by default. The model records its file path,
item count, and generation timestamp.
Download endpoint
The package registers a token-protected download route by default:
GET /product-feeds/{token}
The route returns the most recently generated file. The token is compared by
hash; the plaintext token is never stored. Disable the route or customize its
prefix and middleware in config/product-feeds.php.
Supported formats
- CSV
- XML
- JSON
Supported filter operators
equalsnot_equalsnot_nullcontainsgreater_thangreater_than_or_equalless_than
All configured filters are combined using AND logic. Filters apply to mapped output fields, not directly to arbitrary database query expressions.
Scheduled generation
Use Laravel Scheduler and a queued job or application command to fetch products
and call generate(). The package deliberately does not assume a product
catalog schema or register a schedule automatically.
Security notes
- Feed tokens are generated using a cryptographically secure random source.
- Only SHA-256 token hashes are persisted.
- The plaintext token is returned only during feed creation.
- Treat feed URLs as secrets and rotate them by creating a replacement feed token through your application's administrative workflow.
- The download endpoint returns 404 for inactive feeds or feeds without a generated file.
Scope boundaries
This package generates and serves feeds. It does not connect to Google Merchant Center, Meta Catalog, TikTok Shop, marketplaces, or supplier APIs; does not import products; and does not synchronize remote channel status. Implement channel-specific submission and scheduling in your application or future integration packages.
Testing
composer install
composer test
License
MIT.