PHP code example of tourze / wechat-mini-program-log-bundle
1. Go to this page and download the library: Download tourze/wechat-mini-program-log-bundle 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/ */
tourze / wechat-mini-program-log-bundle example snippets
use WechatMiniProgramLogBundle\Repository\ErrorDetailRepository;
class MyService
{
public function __construct(
private ErrorDetailRepository $errorDetailRepository
) {}
public function findRecentErrors(): array
{
return $this->errorDetailRepository->findBy(
['date' => new \DateTime('-7 days')],
['createTime' => 'DESC'],
10
);
}
}
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ErrorEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
'wechat.error.created' => 'onErrorCreated',
];
}
public function onErrorCreated(ErrorEvent $event): void
{
// Custom error handling logic
}
}