1. Go to this page and download the library: Download logstream/laravel-sdk 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/ */
$log->log('error', 'Something went wrong', ['code' => 500]);
use LogStream\Laravel\LogStreamChannel;
'channels' => [
'logstream' => [
'driver' => 'custom',
'via' => LogStreamChannel::class,
'url' => env('LOGSTREAM_URL'),
'token' => env('LOGSTREAM_TOKEN'),
'source' => env('LOGSTREAM_SOURCE', 'my-app'),
],
// To log both locally and to LogStream at the same time:
'stack' => [
'driver' => 'stack',
'channels' => ['daily', 'logstream'],
],
],
Log::info('User authenticated', ['user_id' => 42]);
Log::error('Payment failed', ['order_id' => 99]);
// Or send only to LogStream:
Log::channel('logstream')->warning('Rate limit reached');
use LogStream\LogStreamClient;
use LogStream\Logger\LogStreamLogger;
$client = new LogStreamClient('https://your-logstream.com', 'src_token', 'my-app');
$logger = new LogStreamLogger($client);
// $logger now implements Psr\Log\LoggerInterface
$logger->info('Hello', ['user_id' => 1]);
class PaymentService
{
public function __construct(private \Psr\Log\LoggerInterface $logger) {}
public function process(int $orderId): void
{
$this->logger->info('Processing payment', ['order_id' => $orderId]);
}
}
$service = new PaymentService(new LogStreamLogger($client));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.