PHP code example of nexylan / graylog-sdk

1. Go to this page and download the library: Download nexylan/graylog-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nexylan / graylog-sdk example snippets


$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);

// config/bundles.php

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

class MyService
{
    private $graylog;

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