PHP code example of thecodingcompany / php-fluentd-mariadb

1. Go to this page and download the library: Download thecodingcompany/php-fluentd-mariadb 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/ */

    

thecodingcompany / php-fluentd-mariadb example snippets


## built-in TCP input
## @see http://docs.fluentd.org/articles/in_forward
## @see https://docs.fluentd.org/v0.12/articles/out_exec_filter
<source>
  @type forward
  @label @PHP_FILE
  port 2017
  bind 127.0.0.1
  @log_level debug
</source>
<label @PHP_FILE>
    <match php_out>
        #@type stdout
        @type exec_filter
        command /bin/php /usr/local/example.php 2>&1
        in_format json
        out_format json
        flush_interval 1s
        tag php_out
        @log_level debug
    </match>
</label>


tings = array(
    "cdn"       => "mysql:host=127.0.0.1;port=3306;dbname=event_log;",
    "username"  => "root",
    "password"  => "MySecretPassword"
);

/*
* Example data: {"attributes":{"voornaam":"Victor","achternaam":"Angelier"}} that is forwarded from FluentD to STDIN
*/
$fields = array("attributes");

$maria = new theCodingCompany\MariaDBStore($settings);
$maria->setTable("event_log")
    ->setFields($fields)
    ->start();