PHP code example of larva / volcengine-tls-sdk-php
1. Go to this page and download the library: Download larva/volcengine-tls-sdk-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/ */
use Larva\Volc\MonologHandler;
use Larva\Volc\TlsLoggingFormatter;
use Monolog\Logger;
$handler = new MonologHandler(
$ak,
$sk,
'https://tls-cn-beijing.volces.com',
'topic-id',
'cn-beijing'
);
$handler->setFormatter(new TlsLoggingFormatter());
$logger = new Logger('tls');
$logger->pushHandler($handler);
$logger->info('Hello TLS', ['user_id' => 123]);
use Larva\Volc\MonologHandler2;
use Larva\Volc\TlsLoggingFormatter2;
use Monolog\Logger;
$handler = new MonologHandler2(
$ak,
$sk,
'https://tls-cn-beijing.volces.com',
'topic-id',
'cn-beijing'
);
$handler->setFormatter(new TlsLoggingFormatter2());
$logger = new Logger('tls');
$logger->pushHandler($handler);
'tls' => [
'driver' => 'custom',
'via' => function ($config) {
$handler = new \Larva\Volc\MonologHandler(
env('TLS_AK'),
env('TLS_SK'),
env('TLS_ENDPOINT', 'https://tls-cn-beijing.volces.com'),
env('TLS_TOPIC_ID'),
env('TLS_REGION', 'cn-beijing')
);
$handler->setFormatter(new \Larva\Volc\TlsLoggingFormatter());
return tap(new \Monolog\Logger('tls'), function ($logger) use ($handler) {
$logger->pushHandler($handler);
});
},
],
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.