inteve/feed-generator
Composer 安装命令:
composer require inteve/feed-generator
包简介
Feed generator
README 文档
README
Installation
Download a latest package or use Composer:
composer require inteve/feed-generator
Feed Generator requires PHP 5.6.0 or later.
Usage
-
Feeds
-
Outputs
-
Integrations
Feeds
Google Merchant
use Inteve\FeedGenerator\Feeds\GoogleMerchant; $feed = new GoogleMerchant\GoogleMerchantFeed; $feed->setTitle('Products'); $feed->setWebsiteUrl('http://www.example.com/'); $feed->setUpdated(new DateTime('2017-01-01 00:00:00 UTC')); $feed->setAuthor('Example.com'); $items = array(); foreach ($products as $product) { $item = new GoogleMerchant\GoogleMerchantItem; $item->setId($product->id) ->setTitle($product->title) ->setDescription($product->description) ->setUrl('https://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setAvailability($product->qty > 0 ? $item::AVAILABILITY_IN_STOCK : $item::AVAILABILITY_OUT_OF_STOCK) ->setPrice($product->price, 'USD'); $items[] = $item; } $feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(__DIR__ . '/feeds/google.xml'));
Glami.cz
use Inteve\FeedGenerator\Feeds\Glami; $feed = new Glami\GlamiFeed; $items = array(); foreach ($products as $product) { $items[] = Glami\GlamiItem::create() ->setId($product->id) ->setProductName($product->name) ->setDescription($product->description) ->setCategoryText($product->categoryName) ->setUrl('http://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setPriceVat($product->price) ->setDeliveryDate($product->qty > 0 ? 0 : 10) // number of days ->addParameter('velikost', 'XS'); } $feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(__DIR__ . '/feeds/glami.xml'));
Heureka.cz
use Inteve\FeedGenerator\Feeds\Heureka; $feed = new Heureka\HeurekaFeed; $items = array(); foreach ($products as $product) { $items[] = Heureka\HeurekaItem::create() ->setId($product->id) ->setProductName($product->name) ->setDescription($product->description) ->setCategoryText($product->categoryName) ->setUrl('http://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setPrice($product->price) ->setDeliveryDate($product->qty > 0 ? 0 : 10); // number of days or DateTime } $feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(__DIR__ . '/feeds/heureka.xml'));
Zbozi.cz
use Inteve\FeedGenerator\Feeds\Zbozi; $feed = new Zbozi\ZboziFeed; $items = array(); foreach ($products as $product) { $items[] = Zbozi\ZboziItem::create() ->setId($product->id) ->setProductName($product->name) ->setDescription($product->description) ->setUrl('http://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setPrice($product->price) ->setDeliveryDate($product->qty > 0 ? 0 : 10); // number of days or DateTime } $feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(__DIR__ . '/feeds/zbozi.xml'));
Outputs
FileOutput
Sends output to file.
$output = new Inteve\FeedGenerator\Outputs\FileOutput('/path/to/destination/feed.xml'); $feed->generate($output);
DirectOutput
Sends output to STDIN.
$output = new Inteve\FeedGenerator\Outputs\DirectOutput; $feed->generate($output);
MemoryOutput
Saves output in memory.
$output = new Inteve\FeedGenerator\Outputs\MemoryOutput; $feed->generate($output); echo $output->getOutput();
Integrations
Nette
Requires package nette/application.
$response = new FeedGenerator\Responses\NetteDownloadResponse($feed, 'filename'); $presenter->sendResponse($response);
For example:
class FeedPresenter extends Nette\Application\UI\Presenter { public function actionGoogle() { $feed = new FeedGenerator\Feeds\GoogleMerchant\GoogleMerchantFeed; // prepare feed & items $response = new FeedGenerator\Responses\NetteDownloadResponse($feed, 'google.xml'); $this->sendResponse($response); } }
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/
inteve/feed-generator 适用场景与选型建议
inteve/feed-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.28k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 inteve/feed-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inteve/feed-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-04-04