ipunkt/laravel-indexer-client

laravel-indexer-service 的 PHP 客户端

2.1.0 2019-03-14 17:33 UTC

This package is auto-updated.

Last update: 2024-09-15 20:33:39 UTC


README

Latest Stable Version Latest Unstable Version License Total Downloads

laravel-indexer-service 的 PHP 客户端。laravel-indexer-service.

安装

composer require ipunkt/laravel-indexer-client

如果需要 < php7 版本,请使用 1.* 版本。

在 Laravel 中绑定

在任何 ServiceProvider 中执行以下操作

public function register()
{
    $this->app->bind(IndexerClient::class, function () {
        $host = config('indexer.service');
        $token = config('indexer.token');
        try {
            $httpClient = new Client();
            $client = new IndexerClient($host, $httpClient, $token);
            return $client;
        } catch (Exception $exception) {
            throw new \RuntimeException('IndexerClient can not be instantiated.', 0, $exception);
        }
    });
}