PHP code example of treblle / treblle-symfony

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

    

treblle / treblle-symfony example snippets


return [
    // ...
    Treblle\Symfony\TreblleBundle::class => ['all' => true],
];

use Treblle\Symfony\Metadata\MetadataRegistry;

final class OrderController extends AbstractController
{
    public function __construct(private readonly MetadataRegistry $treblle) {}

    #[Route('/orders', methods: ['POST'])]
    public function create(Request $request): JsonResponse
    {
        $this->treblle->add([
            'user-id'  => $this->getUser()?->getId(),
            'plan'     => 'enterprise',
            'tenant'   => 'acme-corp',
        ]);

        // ... handle request
    }
}

$this->treblle->add(['user-id' => 42]);
$this->treblle->add(['plan' => 'pro']);
// payload contains: { user-id: 42, plan: "pro" }
bash
php bin/console messenger:consume treblle --time-limit=3600