1. Go to this page and download the library: Download soloterm/notify-laravel 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/ */
use SoloTerm\Notify\Laravel\Facades\Notify;
// Basic notifications
Notify::send('Message', 'Title');
Notify::send('Message', 'Title', Notify::URGENCY_CRITICAL);
// Semantic methods with default titles from config
Notify::success('Task completed'); // Title: "Success"
Notify::error('Something went wrong'); // Title: "Error", critical urgency
Notify::warning('Check this out'); // Title: "Warning"
Notify::info('FYI'); // Title: "Info", low urgency
// Other methods
Notify::sendOrBell('Message'); // Falls back to bell if unsupported
Notify::sendAny('Message'); // Uses OSC or external fallback
Notify::bell(); // Just the bell character
// In routes/console.php or app/Console/Kernel.php
// Notify after task completes
$schedule->command('backup:run')
->daily()
->thenNotify('Backup complete!');
// Notify with custom title
$schedule->command('reports:generate')
->hourly()
->thenNotify('Reports ready', 'Reports');
// Notify only on success
$schedule->command('sync:data')
->everyFiveMinutes()
->thenNotifySuccess('Sync completed');
// Notify only on failure
$schedule->command('payments:process')
->hourly()
->thenNotifyFailure('Payment processing failed!');
// Notify on both success and failure
$schedule->command('deploy:production')
->daily()
->withNotification(); // Uses command name for messages
// Custom messages for both outcomes
$schedule->command('cleanup:logs')
->weekly()
->withNotification(
successMessage: 'Cleanup finished',
failureMessage: 'Cleanup failed',
title: 'Maintenance'
);
// In config/logging.php
'channels' => [
// ... other channels ...
'notify' => [
'driver' => 'custom',
'via' => \SoloTerm\Notify\Laravel\Logging\CreateNotifyLogger::class,
'level' => 'warning', // Only warning and above
'title' => 'My App',
],
],
use Illuminate\Support\Facades\Log;
// Send to notify channel
Log::channel('notify')->error('Database connection lost!');
Log::channel('notify')->warning('High memory usage');
// Or add to your stack
'stack' => [
'driver' => 'stack',
'channels' => ['daily', 'notify'],
],
use SoloTerm\Notify\Laravel\Facades\Notify;
// Check if the terminal supports progress bars
if (Notify::supportsProgress()) {
// Show progress (0-100)
Notify::progress(25);
Notify::progress(50);
Notify::progress(100);
// Clear when done
Notify::progressClear();
}
// Normal progress (blue/default)
Notify::progress(75);
// Error state (red)
Notify::progressError(100);
// Paused state (yellow)
Notify::progressPaused(50);
// Indeterminate/pulsing
Notify::progressIndeterminate();
// Hide/clear
Notify::progressClear();
// In AppServiceProvider or a dedicated provider
use Illuminate\Queue\Events\JobProcessing;
use Illuminate\Queue\Events\WorkerStopping;
use Illuminate\Support\Facades\Event;
use SoloTerm\Notify\Laravel\Facades\Notify;
public function boot(): void
{
// Notify when queue starts processing (first job only)
$notified = false;
Event::listen(JobProcessing::class, function () use (&$notified) {
if (!$notified) {
Notify::info('Queue worker started processing', 'Queue');
$notified = true;
}
});
// Notify when queue worker stops
Event::listen(WorkerStopping::class, function () {
Notify::warning('Queue worker stopping', 'Queue');
});
}
namespace App\Console\Commands;
use Illuminate\Console\Command;
use SoloTerm\Notify\Laravel\Concerns\SendsNotifications;
class BuildProject extends Command
{
use SendsNotifications;
protected $signature = 'build:project';
public function handle(): int
{
$this->info('Building project...');
// ... build logic ...
// Simple notification
$this->notify('Build completed!', 'Build');
// Convenience methods with preset titles
$this->notifySuccess('All tests passed');
$this->notifyError('Build failed');
$this->notifyWarning('Low disk space');
// Check if notifications are supported
if ($this->canNotify()) {
$this->notify('This terminal supports notifications!');
}
return self::SUCCESS;
}
}