alleyinteractive/logger
A Laravel logging package from Alley Interactive that builds on Monolog and PSR-3 with context-aware helpers, making it easy to automatically attach request, user, and application context to log entries and route them to your configured handlers for cleaner, more traceable logs.
v2.6.4 is an additive release: it introduces basic Slack notification support. No breaking changes or deprecations are listed, so existing integrations should continue to work after a normal composer update.
Start by checking:
config/<package>.php) for new Slack-related keys.Minimal setup:
composer update <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\\<Package>\\<PackageServiceProvider>" --tag=config
php artisan config:clear
Add the required Slack credentials to .env — typically a webhook URL or bot token, plus a default channel:
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
SLACK_CHANNEL=#deployments
Verify end-to-end before wiring it into application events:
php artisan tinker
app(<PackageSlackNotifier>::class)->send('Test from staging');
The first practical use case is low-risk operational signalling: deploy notifications, failed scheduled jobs, or exception summaries to an internal channel. Treat it as a “basic” transport and confirm the capabilities in the README before relying on it for anything with formatting or delivery guarantees.
Wrap it behind an application-level notifier. Don’t call the package’s Slack API directly from controllers or models. Introduce a small service or dedicated Laravel notification classes so the package remains an implementation detail:
final class SlackAlert
{
public function __construct(private PackageSlackNotifier $slack) {}
public function deploymentFailed(Deployment $deployment): void
{
$this->slack->send(sprintf(
'Deployment %s failed for %s',
$deployment->id,
$deployment->environment
));
}
}
Drive it from events and listeners. Keeps business flow decoupled and makes it easy to disable notifications in tests or local environments:
Event::listen(DeploymentFailed::class, function (DeploymentFailed $event) {
app(SlackAlert::class)->deploymentFailed($event->deployment);
});
Queue notifications. Slack is an external HTTP dependency; never let it sit in the request path. If the package exposes a Laravel notification channel, implement ShouldQueue and use afterCommit() so you don’t announce something that was rolled back:
final class DeploymentFailedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(public Deployment $deployment)
{
$this->afterCommit();
}
public function via(object $notifiable): array
{
return ['slack'];
}
}
Separate channels by environment. Route staging and production to different Slack channels, and disable entirely in local/testing. Prefer config-driven routing over hardcoded channel names:
'slack' => [
'webhook' => env('SLACK_WEBHOOK_URL'),
'channel' => env('SLACK_CHANNEL', '#general'),
'enabled' => env('SLACK_NOTIFICATIONS_ENABLED', false),
],
Test with fakes, not real HTTP. Use Notification::fake() or Http::fake() depending on how the package sends. Assert that the notification was dispatched and, where possible, assert the channel and payload shape:
Notification::fake();
$this->post('/deployments/fail', $payload);
Notification::assertSentOnDemand(DeploymentFailedNotification::class);
Use it for scheduled-task and health-check visibility. A scheduled command that reports failures to Slack is one of the highest-value, lowest-effort integrations:
$schedule->command('reports:generate')
->daily()
->onFailure(fn () => app(SlackAlert::class)->jobFailed('reports:generate'));
.env/secret storage, exclude them from logs, and never echo the full URL in exception messages. A leaked webhook allows anyone to post to your channel.php artisan config:clear (or config:cache in deploy). A stale config cache is the most common reason “the notification silently doesn’t send.”php artisan queue:restart should be part of your deployment pipeline.failed() on queued notifications. A Slack outage should never fail a deployment, payment, or job.afterCommit() for anything transaction-adjacent. Otherwise you may announce records that were rolled back.vendor:publish --force, which will overwrite customisations.How can I help you explore Laravel packages today?