1. Go to this page and download the library: Download monitaroo/monitaroo-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/ */
monitaroo / monitaroo-symfony example snippets
public function registerBundles()
{
$bundles = [
// ...
new Monitaroo\Symfony\MonitarooBundle(),
];
}
use Monitaroo\Client;
class MyController
{
private $monitaroo;
public function __construct(Client $monitaroo)
{
$this->monitaroo = $monitaroo;
}
public function index()
{
// Logging
$this->monitaroo->info('User logged in', ['user_id' => 123]);
$this->monitaroo->error('Payment failed', ['order_id' => 456]);
// Metrics
$this->monitaroo->increment('orders.completed');
$this->monitaroo->gauge('queue.size', 42);
$this->monitaroo->timing('api.response_time', 145.5);
// Timer helper
$stop = $this->monitaroo->startTimer('db.query');
$users = $this->repository->findAll();
$stop(); // Records the timing
}
}
use Psr\Log\LoggerInterface;
class MyService
{
public function __construct(private LoggerInterface $logger)
{
}
public function doSomething()
{
$this->logger->info('Something happened');
}
}