PHP developers of all experiences are painfully aware that your script may not execute if it takes longer than 30 seconds to process. There’s nothing worse than failing to do proper testing and finding that your code doesn’t scale in production.

In a previous tutorial, I shared how you can  calculate the script execution time of sending SMS messages. At the conclusion we discovered that each message takes about .33 seconds to send, meaning that PHP’s 30 second timeout will allow you to send 90 messages before failure.

So what do you do when you want to send more than 90 messages? What about 1000?

Unfortunately, if you want to send bulk SMS (or WhatsApp) messages using the standard  Programmable Messaging API, it’s not going to scale in PHP. Great engineering practices would suggest that you break apart your requests and run batches asynchronously. However, Twilio engineering has provided another service specifically for bulk sending called Twilio Notify.

In this quick tutorial, we will learn how to send bulk SMS in PHP using  Twilio Notify.

Set Up a New Project Folder

Even though this tutorial only requires one script to execute, we will need a folder to store the dependencies required to securely connect to the Twilio Notify API. We will be using Composer to include the Twilio SDK along with .env files to securely store the Twilio credentials.

#code #tutorials and hacks #php

How to Send 1000 (or More) Text Messages in PHP without Timing Out
1.60 GEEK