PHP code example of abdulsalam / laravel-context-flow
1. Go to this page and download the library: Download abdulsalam/laravel-context-flow 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/ */
abdulsalam / laravel-context-flow example snippets
use Illuminate\Support\Facades\Context;
Context::add('tenant_id', $tenant->id);
Context::add('actor_id', auth()->id());
Context::add('locale', app()->getLocale());
CreateWithdrawalJob::dispatch($withdrawal);
use Abdulsalam\LaravelContextFlow\Contracts\ContextEnricher;
final class AuthContextEnricher implements ContextEnricher
{
public function enrich(): array
{
return [
'actor_id' => auth()->id(),
];
}
}
use Abdulsalam\LaravelContextFlow\Testing\InteractsWithContextFlow;
class WithdrawalTest extends TestCase
{
use InteractsWithContextFlow;
public function test_context(): void
{
// ...
$this->assertCorrelationIdExists();
$this->assertContextValue('tenant_id', 12);
}
}