logshub/search-client-php

此包最新版本(1.3)没有可用的许可信息。

1.3 2019-04-11 13:33 UTC

This package is auto-updated.

Last update: 2024-09-21 21:19:39 UTC


README

您可以使用它来管理您的搜索服务。这是您的商店和logshub.com搜索服务之间的主要连接器。大多数商店都是用PHP语言编写的,我们决定创建此连接器以加快集成速度。

要求

安装

composer require logshub/search-client-php

测试

make test

示例

<?php
include_once 'vendor/autoload.php';

# you can find your service's details on your logshub.com dashboard.
$location = 'uk01';
$serviceId = '5b5a06d2-23bc-4186-4d1b-3a17bfa7200d';
$apihash = 'xizinISDPH';
$apiSecret = 'ZJLnvZAujIBOTiJVyfImZYLEKdesJPKUntfFztYLiefQsCMgmd';
$client = \Logshub\SearchClient\Client::fromLocation(
   $location, $apihash, $apiSecret);

$product = new \Logshub\SearchClient\Model\Product('1', [
   'name' => 'Laptop Full HD 8GB RAM',
   'price' => 899
]);
$request = new \Logshub\SearchClient\Request\IndexProducts($serviceId, [
   $product
]);
$response = $client->indexProducts($request);

echo $response->getBody() . PHP_EOL;

更多信息请参阅文档

演示用法

用于演示的配置文件内容,必需

# example content of /etc/logshub-search.ini - replace with your details,
# that can be found on your logshub's service details page
serviceid = "5b5a06d2-23bc-4186-4d1b-3a17bfa7200d"
location = "uk01"
apihash = "xizinISDPH"
apisecret = "ZJLnvZAujIBOTiJVyfImZYLEKdesJPKUntfFztYLiefQsCMgmd"

索引

php vendor/bin/logshub-search index \
--config /etc/logshub-search.ini \
--id 4 \
--name "Laptop for gaming asus" \
--price 15.5

搜索

php vendor/bin/logshub-search search \
--config /etc/logshub-search.ini \
--query "laptop"

索引CSV文件

php vendor/bin/logshub-search index:csv \
--config /etc/logshub-search.ini \
--csv /home/greg/products.csv

许可

MIT