PHP code example of technobase / alert

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

    

technobase / alert example snippets


use Illuminate\Support\Facades\Notification;
use Technobase\Alert\Notifications\TestTelegramNotification;

Notification::route('telegram', config('alert.chat_id'))
    ->notify(new TestTelegramNotification('Testing Alert integration'));

Route::get('/test-alert', function() {
    \Notification::route('telegram', config('alert.chat_id'))
        ->notify(new \Technobase\Alert\Notifications\TestTelegramNotification());
    
    return 'Test notification sent!';
});

use Illuminate\Support\Facades\Notification;
use Technobase\Alert\Notifications\TelegramErrorNotification;

try {
    // Your code that might fail
    riskyOperation();
} catch (\Exception $e) {
    Notification::route('telegram', config('alert.chat_id'))
        ->notify(new TelegramErrorNotification(
            title: 'Custom Error Title',
            message: $e->getMessage(),
            context: [
                'file' => $e->getFile(),
                'line' => $e->getLine(),
                'custom_data' => 'additional context',
            ]
        ));
    
    throw $e; // Re-throw if needed
}

'enabled_environments' => [
    'production',
    'staging',
    // 'local' - not 
bash
php artisan vendor:publish --tag=alert-config