1. Go to this page and download the library: Download zerethonapp/flow-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/ */
zerethonapp / flow-laravel example snippets
// Explicitly enable or disable (null = auto-detect based on environment)
'enabled' => env('FLOW_ENABLED'),
// Environments where Flow should NOT run
'except_environments' => ['testing'],
// URI patterns to exclude from tracing
'except' => [
'telescope*',
'horizon*',
],
// Sample rate (0.0 - 1.0): trace only a percentage of requests
'sample_rate' => env('FLOW_SAMPLE_RATE', 1.0),
use Zerethon\Flow\Laravel\Support\Traceable;
class UserService
{
use Traceable;
public function findUser(int $id): User
{
return $this->traceService('UserService.findUser', function () use ($id) {
// Business logic here
return User::find($id);
});
}
public function syncWithExternalApi(): void
{
$this->traceExternal('ExternalUserApi.sync', function () {
// External API call
Http::post('https://api.example.com/sync');
});
}
}
use Zerethon\Flow\Laravel\Support\Trace;
class OrderService
{
#[Trace('service')]
public function processOrder(int $orderId): void
{
// Automatically traced as "OrderService.processOrder"
}
#[Trace('external', 'PaymentAPI.charge')]
public function chargePayment(float $amount): void
{
// Automatically traced with custom label
}
}