Never miss another server outage. Learn how to build a server notification system that will alert all administrators via SMS when a server outage occurs.Start Tutorial
This Laravel sample application demonstrates how to send SMS alerts to a list of system administrators if something goes wrong on your server. In this tutorial, we'll show you the key bits of code to make this work. Head to the application's README to see how to run the app locally.
Let's get started!
Create a list of administrators who should be notified if a
server error occurs. The only requirement we have is a
Each time an exception is raised anywhere in a Laravel
will be used to handle the exception. This is where we will hook
our SMS sending code. It's important to call
parent so the
framework can do its regular error handling as well.
Here we create an alert message to send out via text message. You might also decide to include a picture with your alert message, maybe a screenshot of the application when the crash happened?
Next we read the admins from our JSON
and send alert messages to each of them with the private
There are the three parameters needed to send an
using the Twilio REST
Body. After the message is sent, we print out the phone
number we're texting. US phone
can also send an image with the message.
That's it! We've just implemented an automated server notification system that can send you server alerts if anything goes wrong. If you're a PHP developer working with Twilio, you might want to check out these other tutorials.
Increase the security of your login system by verifying a user's mobile phone in addition to their password.
Send your customers a text message when they have an upcoming appointment - this tutorial shows you how to do it from a background job.
Thanks for checking out this tutorial! If you have any feedback to share with us, we'd love to hear it. Tweet @twilio to let us know what you think.