Twilio Lookup is a phonebook REST API that you can use to check whether a number exists, format international numbers to local standards, determine whether a phone can receive text messages, and even discover information about the carrier associated with that phone number.

In this post, we’re going to learn how to deal with valid and invalid numbers using the Twilio PHP library. Whether you need to look up customer numbers in your production Laravel app or just have a basic script you want to run to check numbers in a local database, this code should get you started with validating phone numbers.

Getting started

We’ll need a few things before we start building: