1. Go to this page and download the library: Download tracegraph/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/ */
tracegraph / laravel example snippets
use Tracegraph\Laravel\Tracegraph;
class ProductService
{
public function create(array $data): Product
{
return Tracegraph::trace('ProductService.create', function () use ($data) {
return Product::create($data);
});
}
public function reserveStock(int $productId, int $qty): void
{
Tracegraph::trace('ProductService.reserveStock', function () use ($productId, $qty) {
// your logic here
});
}
}
use Tracegraph\Laravel\Tracegraph;
public function placeOrder(Request $request): JsonResponse
{
Tracegraph::authCheck('OrderPolicy.canPlace');
$this->authorize('place', Order::class);
// ...
}
// app/Exceptions/Handler.php
use Tracegraph\Laravel\Tracegraph;
public function register(): void
{
$this->reportable(function (\Throwable $e): void {
Tracegraph::captureException($e);
});
}
// Equivalent to Tracegraph::trace()
$result = tracegraph_trace('BatchProcessor.run', fn() => $processor->run($batch));
// Equivalent to Tracegraph::authCheck()
tracegraph_auth_check('can:manage-orders');
// Xdebug correlation anchor (see Xdebug section below)
tracegraph_xdebug_marker('before_payment_gateway');
public function handle(Request $request, Closure $next): Response
{
tracegraph_xdebug_marker('request_start');
return $next($request);
}
bash
php artisan tracegraph:test
bash
php artisan tracegraph:baseline
bash
php artisan tracegraph:compare
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.