Laravel has lots of built-in and advanced features to make any developer impress with. Sending Notifications are one of them. You can send email, SMS or Slack notification with its built-in functionality. In this article, we going to send the slack notification with Laravel.
The gpressutto5/laravel-slack composer package is a Slack notification library for Laravel 5.5 by Guilherme Pressutto:Slack notification for Laravel as it should be. Easy, fast, simple and highly.
- THE SLACK COMMUNITY FOR LARAVEL DEVELOPERS & MORE. Chat and share with over 32,854 worldwide members. We have live discussions. We're building the biggest PHP virtual user group in the world. Come join the fun. Jobs Events Articles Community.
- Get in-depth tutorial on Laravel logging. Explore Monolog and the logging config file. Learn how to how to write and format log messages and use logging levels.
- Laravel - Errors and Logging - This chapter deals with errors and logging in Laravel projects and how to work on them.
- Slack Channel; Our Meetup. Talk About Laravel with Local St. Louis Developers. Meet at T-REX every 3rd Monday of the Month at 5:30pm. Amazing Talk from a Laravel Developer. Learn from one of your peer developers in the St. Each month a new developer will give an incredible talk.
I am going to use Laravel 5.8.x. The setup is pretty easy. If you haven’t setup Laravel yet then please following the Laravel Installation guide from the documentation.
Requirements
- Slack Notification Channel Package
- Configure Incoming Webhooks
Slack Notification Channel


In the older version of Laravel, Slack notification was built-in configured with the framework. But on this 5.8.x version, they have created a separate package for Slack Notification. First of all, we have to install that package in our application.
Configure Incoming Webhooks
After installation of Slack Notification Channel package, we have to collect the Slack Webhook URL. So first of all, login to your slack application. Now on the main screen, navigate the App menu on the left sidebar at the very bottom.
Now click on the + icon to add the incoming-hook app to your slack application. Once you clicked on the + icon, then browse apps screen will pop up on your screen. Just search the incoming-webhook in the search area.
If you haven’t installed the incoming-webhook app on the slack app then please install it. After installation, the incoming-webhook app, navigate the settings tab on the incoming-webhook section and collect the Webhook URL.
Now copy the Webhook URL and paste it to the .env file at the very bottom or whatever you like.
Slack Laravel Api
This is what you need from the Slack app. Now it’s time to create a notification on Laravel. So let’s create our first notification.
The above command will create a Notifications folder on the app folder from where you can find the TestNotification file. So let’s open and start adding it.
Notice the SlackMessage package that we have included on our application.
use IlluminateNotificationsMessagesSlackMessage;Add the slack value in the via method’s returned array and create your first slack notification in the new method named toSlack().
If you like to more customized notification then please follow the documentation link. Now its time to trigger this notification.
Complete code for Notification
Paste the above code to send the notification to your slack channel and that’s all.
Related posts:
- Laravel On-Demand Notifications
- Custom Validation With Laravel
- REST API and Passport Authentication with Laravel
- Understanding Laravel Middleware
- Laravel Notification – Customize markdown email header and footer
- Laravel Mail – Sending Mailable, Markdown Mailable, and Raw HTML
Laravel or anything you are comfortable with making a Route and Response will work fine really.
This 'messaging as a platform' is a new world for me, challenging my way of thinking in many ways. Some things just do not need a authentication of their own, a UI, etc they just need a place to get info from, or do something with some info etc.
In this case I made a really simple 'Custom Slash Command' to translate British Slang to American and American to British (so I can sound cooler!)

Slack Laravel Login
Later I will look into bots etc but for now here is a look at a custom slash commands.
Slack Laravel Tutorial
Getting API Endpoint Setup

I still do not have a great local workflow for this. There are articles about this online with secure tunnels etc. My next step is to use my wildcard cert or using https://letsencrypt.org/ to have a local url so I can make this workflow a ton easier.
But to get going I had to setup a domain with valid HTTPS. As linked above, Let's Encrypt might be a great way to setup a play area and solutions like Forge https://forge.laravel.com/ Heroku https://www.heroku.com/ are great ways to get going quickly on getting a 'POSTABLE' API in place.
What I mean by POSTABLE is that your API needs to take a POST from Slack (it can take a GET but not sure the advantage to that) but consider App you are setting up the foundation to so many cool integrations you can do with Slack all using this one server your are setting up, until of course something needs it's own space. One POSTABLE API can be like your own 'If This Then That' https://ifttt.com/ solution in my opinion. Fun for some of us that is for sure.
Slack Laravel Interview
Once that was setup I could start playing around.
