1. Go to this page and download the library: Download logger/ntfy 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/ */
logger / ntfy example snippets
use Logger\Ntfy\NtfyClient;
use Logger\Ntfy\NtfyConfiguration;
use Logger\Ntfy\NtfyExceptionConfiguration;
use Logger\Ntfy\NtfyLogger;
use Nyholm\Psr7\Factory\Psr17Factory;
use Symfony\Component\HttpClient\Psr18Client;
$psr17 = new Psr17Factory();
$client = new NtfyClient(
client: new Psr18Client(),
requestFactory: $psr17,
streamFactory: $psr17,
config: new NtfyConfiguration(
topic: 'my-alerts',
token: 'tk_your_access_token',
),
);
$logger = new NtfyLogger($client);
$logger->info('Import finished for order {orderId}', [
'orderId' => 12345,
]);
$logger->error('Background job failed', [
'title' => 'Worker error',
'tags' => ['warning', 'computer'],
'click' => 'https://example.com/jobs/12345',
]);
new NtfyConfiguration(
topic: 'my-alerts',
token: 'tk_your_access_token',
serverUrl: 'https://ntfy.sh',
exceptionConfiguration: new NtfyExceptionConfiguration(
basePath: __DIR__,
applicationPaths: ['src', 'modules'],
),
throwOnError: false,
);