nexylan/graylog-sdk

此包已被废弃且不再维护。未建议替代包。

一个用于与Graylog REST API通信的PHP SDK

v0.7.0 2020-05-07 15:34 UTC

This package is auto-updated.

Last update: 2020-11-23 17:10:18 UTC


README

Graylog API PHP SDK。

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

文档

所有安装和用法说明都位于本README中。请查看特定版本

先决条件

本项目版本需要

  • PHP 7.0+

安装

首先,您需要通过Composer要求此库

composer require nexylan/graylog-sdk

用法

$graylog = new \Nexy\Graylog\Graylog([
    'base_uri' => 'https://your.graylog.instance.com/api'
]);

// You may authenticate with API token:
$graylog->auth('YourApiToken');
// Or user credentials:
$graylog->auth('YourGraylogUsername', 'YourGrayLogPassword');

// Then, start using the API:
$result = $graylog->search()->relative()->terms('file', 'source: host.com', 0);

Symfony集成

激活包

// config/bundles.php

return [
    Nexy\Graylog\Bridge\Symfony\Bundle\NexyGraylogBundle::class => ['all' => true],
];

添加配置文件

// config/packages/nexy_graylog.yaml

nexy_graylog:
    options:
        base_uri:             ~ # Required
    auth:

        # Can be a username or a token.
        user:                 ~ # Required

        # Required only for username auth.
        password:             null

然后,通过自动装配注入Graylog服务

class MyService
{
    private $graylog;

    public function __construct(Nexy\Graylog\Graylog $graylog)
    {
        $this->graylog = $graylog;
    }
}