This is a minimal yet professional Laravel 12 project that demonstrates how to send Slack notifications via queued jobs whenever a new user is registered.
It is designed for:
- Clean code architecture
- Queue-friendly design
- Slack integration using Webhooks
- Modern testing using Pest PHP
- SQLite as the local database
✅ Slack webhook integration
✅ Job-based architecture (SendSlackNotification
implements ShouldQueue
)
✅ Environment-based config for security
✅ Full test coverage using Pest
✅ Laravel Queue-ready
✅ Clean code and error logging with Http::fake
, Log::warning
, try/catch
✅ Portable SQLite DB (no need to set up MySQL)
app/
├── Jobs/
│ └── SendSlackNotification.php # Core job logic
config/
├── slack.php # Slack webhook config
database/
├── database.sqlite # Local DB
routes/
├── web.php # Test route to trigger notification
tests/
├── Feature/
│ └── SendSlackNotificationTest.php # Pest-powered test cases
git clone https://github.com/your-username/laravel-slack-observer-demo.git
cd laravel-slack-observer-demo
composer install
cp .env.example .env
php artisan key:generate
touch database/database.sqlite
Edit your .env
:
SLACK_NEW_REGISTRATION_WEBHOOK=https://hooks.slack.com/services/...
Add to config/slack.php
:
return [
'webhook_urls' => [
'new_registration' => env('SLACK_NEW_REGISTRATION_WEBHOOK'),
],
];
php artisan migrate
php artisan serve
Visit:
📍 http://localhost:8000/test-user
✅ If everything works, you'll see a Slack notification posted.
php artisan test
Output:
PASS Tests\Feature\SendSlackNotificationTest
✓ sends Slack message successfully
✓ logs error if Slack webhook fails
✓ logs exception if Slack call throws
- Laravel 10+
- PHP 8.2+
- Pest PHP for testing
- SQLite for local dev
- Slack Incoming Webhooks
- Laravel Queues (sync driver)
👋 Mohammad Umair
Senior Laravel Developer | 15+ Years of Experience
Remote from 🇮🇳 | Seeking full-time remote roles
🔗 LinkedIn | 🔗 GitHub
- Add support for Discord / Teams notifications
- Add notification throttling / retry
- Publish as a Laravel package
If you found this useful, consider giving it a ⭐ on GitHub — it helps boost visibility for more developers.
This project is open-sourced under the MIT license.