PHP code example of techsea / allstack-laravel

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

    

techsea / allstack-laravel example snippets


use AllStak\Facades\AllStak;
// Log anything
AllStak::log('info', 'User logged in', [
    'user_id' => auth()->id(),
    'timestamp' => now()->toDateTimeString(),
]);
// Track errors
try {
    $this->riskyOperation();
} catch (\Exception $e) {
    AllStak::captureError($e, request(), [
        'handled' => true,
        'operation' => 'riskyOperation',
    ]);
}
// Monitor performance
$span = AllStak::startSpan('payment_processing');
$result = $this->processPayment($order);
$span['attributes']['order_id'] = $order->id;
AllStak::endSpan($span, 'OK');
// Force immediate send
AllStak::flush();

Route::get('/test-allstak', function() {
    AllStak::log('info', 'AllStak is working!', ['test' => true]);
    AllStak::flush();
    return 'Check your AllStak dashboard!';
});

// Error tracking
AllStak::captureError(Throwable $e, ?Request $request, array $context): bool
// Logging
AllStak::log(string $level, string $message, array $attributes): bool
// Performance monitoring
AllStak::startSpan(string $name, ?string $parentSpanId): array
AllStak::endSpan(array $span, string $status, ?string $message): bool
// Database tracking
AllStak::captureQuery(string $sql, array $bindings, float $duration, 
                     string $connection, bool $success, ?string $error): bool
// Batch management
AllStak::flush(): bool
// ID generation
AllStak::generateTraceId(): string  // 32-char hex (OpenTelemetry)
AllStak::generateSpanId(): string   // 16-char hex (OpenTelemetry)

AllStak::log('test', 'Test message');
AllStak::flush();
bash
php artisan vendor:publish --tag=allstak-config
bash
php test_suite.php