1. Go to this page and download the library: Download coffee-r/tekagami-php 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/ */
coffee-r / tekagami-php example snippets
use CoffeeR\Tekagami\Collector;
use CoffeeR\Tekagami\Config;
use CoffeeR\Tekagami\Flow;
use CoffeeR\Tekagami\Http\HttpInput;
use CoffeeR\Tekagami\Http\HttpResponse;
use CoffeeR\Tekagami\Sink\JsonlSink;
use CoffeeR\Tekagami\Sql\SqliteSqlAnalyzer;
$collector = new Collector(
new Config(getenv('TEKAGAMI_SECRET') ?: null),
new JsonlSink('/var/log/tekagami/your-app.production.jsonl'),
new SqliteSqlAnalyzer()
);
$http = new HttpInput($request->method(), $request->path());
$http->pathPattern = '/products/{id}';
$http->queryRaw = $request->query();
$http->requestRaw = $requestBody;
$http->requestHeadersRaw = $requestHeaders;
$collector->start($http);
// Use Flow only when a development or QA scenario needs explicit correlation.
// $collector->start($http, new Flow('qa-order-cod-001', 1));
// Preferred: placeholder SQL plus binds.
$collector->addSql($sql, $binds, ['source' => 'db-wrapper']);
// Fallback: expanded SQL from last_query() or query history.
$collector->addExpandedSql($db->last_query(), ['source' => 'ci3-last_query']);
// Stable labels can act as observation anchors for important branches.
$collector->addCustom('purchase_limit_rejected', ['reason' => 'one_time']);
$response = new HttpResponse();
$response->status = http_response_code();
$response->responseKind = 'json';
$response->contentType = 'application/json';
$response->responseHeadersRaw = $responseHeaders;
$response->responseBodyRaw = $responseData;
$collector->finish($response);
new Config($secret = null, array $options = [])
$collector = new Collector(
$config,
$sink,
new CoffeeR\Tekagami\Sql\OracleSqlAnalyzer()
);