PHP code example of alan / swoft-opentracing

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

    

alan / swoft-opentracing example snippets


'db'                => [
  'class'    => Database::class,
  'dsn'      => env("MYSQL_PROVIDERS_DSN"),
  'username' => env("MYSQL_PROVIDERS_USERNAME"),
  'password' => env("MYSQL_PROVIDERS_PASSWORD"),
  'charset'  => 'utf8',
  'prefix'   => 'gpi_',
  'connections' => [
    'mysql' => \bean(swoft\opentracing\Mysql\MySqlConnection::class),
  ]
],

'redis'               => [
  'class'         => \Swoft\Redis\RedisDb::class,
  'host'          => env("TICKET_REDIS_HOST"),
  'port'          => env("TICKET_REDIS_PORT"),
  'database'      => env("TICKET_REDIS_DATABASE"),
  'retryInterval' => 10,
  'readTimeout'   => 0,
  'timeout'       => 2,
  'password'      => env("TICKET_REDIS_PASSWORD"),
  'connections'   => [
    'phpredis' => \bean(swoft\opentracing\Redis\PhpRedisConnection::class)
  ],
  'driver'        => 'phpredis'
],


  
namespace App\Http\Middleware;

use Psr\Http\Server\MiddlewareInterface;
use Swoft\Bean\Annotation\Mapping\Bean;
use swoft\opentracing\Middleware\TracingMiddlewareTrait;


/**
 * Class TracingMiddleware
 * @package App\Http\Middleware
 *
 * @Bean()
 */
class TracingMiddleware implements MiddlewareInterface
{
    use TracingMiddlewareTrait;
}

'httpDispatcher'    => [
  'middlewares'      => [
    \App\Http\Middleware\TracingMiddleware::class,
  ],