PHP code example of otternq / dtail

1. Go to this page and download the library: Download otternq/dtail 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/ */

    

otternq / dtail example snippets




use Colors\Color;

use Aws\Common\Aws;
use Aws\DynamoDb\DynamoDbClient;

use DTail\DTail;

$config = array(
    'dyn-table' => 'PHPErrors',
    'dyn-key'    => YOUR_AWS_KEY,
    'dyn-secret' => YOUR_AWS_SECRET,
    'dyn-region' => 'us-east-1'
);

$dynamodbClient = DynamoDbClient::factory(array(
    'key'    => $config['dyn-key'],
    'secret' => $config['dyn-secret'],
    'region' => $config['dyn-region'],
    )
);

$dtail = new DTail($dynamodbClient);

$iterator = $dtail->get(
    $config['dyn-table'], 
    'PHPErrorReporter'
);

foreach($iterator as $item) {
    var_dump($item);
}


return array(
    'dyn-table' => 'PHPErrors',
    'dyn-key'    => YOUR_AWS_KEY,
    'dyn-secret' => YOUR_AWS_SECRET,
    'dyn-region' => 'us-east-1'
);

Channel           Date Time   Level      Message                                                      Context
PHPErrorReporter  2013-11-14  WARNING    Test                                                         []
PHPErrorReporter  2013-11-14  WARNING    E_WARNING: Division by zero                                  {"file":"/path/to/DTail/app.php","line":26}
PHPErrorReporter  2013-11-14  NOTICE     E_NOTICE: Undefined variable: foo                            {"file":"/path/to/DTail/error.php","line":27}
PHPErrorReporter  2013-11-14  WARNING    E_WARNING: Division by zero                                  {"file":"/path/to/DTail/error.php","line":28}
PHPErrorReporter  2013-11-14  NOTICE     E_NOTICE: Use of undefined constant T - assumed 'T'          {"file":"/path/to/DTail/error.php","line":29}
PHPErrorReporter  2013-11-14  ERROR      Uncaught exception                                           {"exception":{"class":"Exception","message":"$arr has no element with index: dyn->key","file":"/path/to/DTail/Utils/Arr.php:26","trace":["/path/to/DTail/bin/app.php:36"]}}