mnsr / laravel-slack
Package makes send notifications to slack channel easier
v1.0.1
2022-07-17 12:34 UTC
Requires
- laravel/framework: ^6.0|^7.0|^8.0|^9.0
This package is not auto-updated.
Last update: 2025-07-14 09:01:36 UTC
README
Create slack webhook
Slack API webhook official documentation
Add variables to .env
# Add if you have a proxy (Ex. http://192.168.1.1:3128)
PROXY_URL=
# Get from Slack Api
LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx/yyy/zzz
# Your default slack channel
SLACK_DEFAULT_CHANNEL="my_channel"
Then clear config
php artisan config:cache
Use functions directly in your code
$msg // required parameter
$title // optional parameter
slack_emergency($msg, $title);
slack_alert($msg, $title);
slack_critical($msg, $title);
slack_error($msg, $title);
slack_warning($msg, $title);
slack_notice($msg, $title);
slack_info($msg, $title);
slack_debug($msg, $title);
Example
try{
// My Code xx ...
slack_info('code xx finished successfully ..', 'my lovely title');
// My Code yyy ...
}catch (Exception $exception){
slack_error($exception->getMessage());
}