Installation
Run composer require adhocrat-io/arkhe-watcher and execute php artisan arkhe:watcher:install.
This handles config, migrations, and UI integration automatically.
Prerequisites Check Ensure your project meets requirements:
adhocrat-io/arkhe-main ^3.2First Use Case
Access the dashboard at /administration/watcher to monitor:
Automatic Instrumentation
The package hooks into Laravel’s core events (e.g., Illuminate\Http\Kernel::handle) and queues (e.g., job.processed) without manual setup.
Example: No need to wrap DB::query()—queries are auto-captured.
Flux UI Integration Uses Arkhè Main’s Flux 2 dashboard for a reactive, collapsible UI.
Configuration
Key settings in config/watcher.php:
'enabled' => env('WATCHER_ENABLED', true), // Toggle globally
'max_entries' => 1000, // Retention limit
'ignored_exceptions' => [\Symfony\Component\HttpKernel\Exception\HttpException::class], // Exclude noise
Customization
watcher_entries (e.g., user_agent for requests).WatcherController:
public $statusFilter = 'success';
protected $queryString = ['statusFilter'];
Permissions
The installer grants view-watcher to root/administrator roles. Extend via Arkhè’s role system:
// app/Providers/ArkheServiceProvider.php
Arkhe::role('developer')->givePermission('view-watcher');
Performance Overhead
'log_queries' => false in config.watcher_entries size; adjust max_entries or add a scheduled cleanup:
// app/Console/Commands/CleanWatcherEntries.php
use Illuminate\Support\Facades\DB;
DB::table('watcher_entries')->where('created_at', '<', now()->subDays(30))->delete();
Migration Conflicts
watcher_entries, run php artisan arkhe:watcher:install --force to republish migrations.Flux/Livewire Quirks
php artisan view:clear) if the Watcher menu doesn’t appear.public properties in WatcherController are marked with protected $queryString for URL persistence.Exception Ignoring
ignored_exceptions may hide critical errors. Test with:
'ignored_exceptions' => [
\Symfony\Component\HttpKernel\Exception\HttpException::class,
// Except 500s
!\Symfony\Component\HttpKernel\Exception\HttpException::class => function ($e) {
return $e->getStatusCode() !== 500;
},
],
Log Inspection
Check storage/logs/laravel.log for Watcher-related errors (e.g., missing Arkhè Main dependencies).
Entry Debugging Dump raw entries via Tinker:
php artisan tinker
>>> \App\Models\WatcherEntry::latest()->first()->toArray();
UI Debugging
resources/css/app.css includes @source from the installer.Livewire or Flux warnings.Custom Entry Types
Extend the WatcherEntry model (published in app/Models/WatcherEntry.php after installation):
// Add a custom column
public function setCustomAttribute($key, $value) {
$this->attributes[$key] = $value;
}
Event Hooks
Listen for watcher.entry.created to process entries post-save:
// app/Providers/EventServiceProvider.php
protected $listen = [
\Adhocrat\Watcher\Events\EntryCreated::class => [
\App\Listeners\ProcessWatcherEntry::class,
],
];
Dashboard Widgets
Add custom Flux widgets to the Watcher page by extending the WatcherController:
// app/Http/Livewire/WatcherController.php
public function mount() {
$this->customWidget = new \App\Widgets\QueryDurationWidget();
}
How can I help you explore Laravel packages today?