deltasystems / graylog-sdk
A PHP sdk to communicate with the Graylog REST API
v0.8.5
2024-06-04 19:43 UTC
Requires
- php: ^7.0 | ^8.0
- php-http/client-common: ^2.0
- php-http/discovery: ^1.0
- php-http/guzzle7-adapter: ^0.1.1
- php-http/httplug: ^2.0
- symfony/options-resolver: ^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- guzzlehttp/psr7: ^1.3
- php-http/message: ^1.3
- sllh/php-cs-fixer-styleci-bridge: ^2.1
- symfony/dependency-injection: ^2.8 || ^3.0 || ^4.0
- symfony/http-kernel: ^2.8 || ^3.0 || ^4.0
Suggests
- ext-solr: For Lucene query escaping.
- internations/solr-utils: For Lucene query escaping.
- symfony/dependency-injection: For Symfony integration as a bundle
- symfony/http-kernel: For Symfony integration as a bundle
README
Graylog API PHP SDK.
Documentation
All the installation and usage instructions are located in this README. Check it for a specific versions:
Prerequisites
This version of the project requires:
- PHP 7.0+
Installation
First of all, you need to require this library through Composer:
composer require nexylan/graylog-sdk
Usage
$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 integration
Activate the bundle:
// config/bundles.php return [ Nexy\Graylog\Bridge\Symfony\Bundle\NexyGraylogBundle::class => ['all' => true], ];
Add the configuration file:
// 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
Then, inject the Graylog service thanks to autowiring:
class MyService { private $graylog; public function __construct(Nexy\Graylog\Graylog $graylog) { $this->graylog = $graylog; } }