Skip to content

Repository files navigation

Passwordless Authentication With Twilio Verify in PHP

This project demonstrates how to implement passwordless authentication via OTP in PHP using Twilio Verify.

Prerequisites

To run the app locally, you need the following:

  • PHP 8.4 or above

  • Composer installed globally

  • Your preferred code editor or IDE

  • Some terminal experience is helpful, though not required

Quickstart

Core setup

To set up the project:

  • Clone it locally

  • Change into the project directory

  • Install the project’s dependencies with Composer

Set the required environment variables

Here is a list of the environment variables that need to be set in .env, along with what they’re for:

Table 1. Required environment variables

Variable

Format

Where to find

TWILIO_ACCOUNT_SID

Starts with AC.

A {twilio-account-sid}[Twilio Account SID] can be found on {twilio-console}[the Twilio Console] dashboard under Account Info.

TWILIO_AUTH_TOKEN

32-char string. Treat it as a password.

TWILIO_VERIFY_SERVICE_SID

32-char string. Starts with VA.

The Twilio Console → Verify → Services. Find out more detail {twilio-verify-docs}[in the documentation].

Start the application

Finally, start the application running locally.

composer serve

The application will start on port 8080.

Open http://localhost:8080 in your browser of choice, enter your phone number in the form, in {e164-format}[E.164 format], and submit it.

The sign-in form of the application

You’ll be redirected to the OTP verification form, and receive an SMS with a 6-digit OTP code via SMS. Enter the code into the form and submit it.

The verify OTP code form of the application

If the verification was success, you’ll see that confirmed.

Confirmation that the OTP code was successfully verified

Then, if you look in the terminal session or tab where you started the application, you’ll see a log entry similar to the following:

2026/07/16 10:50:00 Verification successful

Contributing

If you want to contribute to the project, whether you have found issues with it or just want to improve it, here’s how:

  • Issues: ask questions and submit your feature requests, bug reports, etc

  • Pull requests: send your improvements

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

About

This project demonstrates how to implement passwordless authentication via OTP in PHP using Twilio Verify.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages