PHP code example of switon / log
1. Go to this page and download the library: Download switon/log 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/ */
switon / log example snippets
use Psr\Log\LoggerInterface;
use Switon\Core\Attribute\Autowired;
class UserService
{
#[Autowired] protected LoggerInterface $logger;
public function login(int $userId): void
{
$this->logger->info('User logged in', ['user_id' => $userId]);
}
}