Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now


Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Twilio Verify Phone Verification PHP Quickstart

Phone Verification is an important, high-confidence step in your registration flow to verify that a user has the device they claim to have. Adding phone verification to your application will greatly reduce your number of fraudulent registrations and protect future application users from having their numbers registered by scammers.

This quickstart guides you through creating a PHP, Laravel and AngularJS app that requires a phone verification step with Twilio Verify to create an account. Two channels of Phone Verification are demoed: SMS and Voice.

デモアプリケーションに電話番号検証を追加して、悪者どもを寄せ付けないようにする準備はできましたか? さぁ、はじめましょう!

Sign into - or create- a Twilio account


新規Account Securityアプリケーションを作成する

Once logged in, visit the Authy Console. Click on the red 'Create New Aplication' (or big red plus ('+') if you already created one) to create a new Authy application then name it something memorable.

Authy create new application


Account Security API Key

Click the eyeball to reveal your Production API Key and copy it somewhere safe. You will use the API Key during the application setup step below.

Install the application prerequisites

To complete the quickstart today we'll use PHP 7.0+, Composer, MySQL, and the Twilio PHP Helper Library. Let's walk through each one now - but feel free to skip if you have already installed one.


When doing web development in PHP, we strongly suggest using Composer for package management. This quickstart relies on Composer to install the PHP Helper library. You can find manual Twilio PHP installation instructions on the PHP Helper Library page.

Install MySQL

While Twilio's Verify API doesn't return user information you'll need to store, to continue working on the app after this Quickstart you'll want a database. For this demo, we built our user database on top of MySQL 5.x.

If you haven't yet installed it, here are instructions for your platform:

When installed, start MySQL. If you're using the default MySQL credentials (as below), create a schema account_security with user homestead and password secret.

Install the quickstart application

Clone our PHP repository locally, then enter the directory:

git clone git@github.com:TwilioDevEd/account-security-quickstart-php.git
cd account-security-quickstart-php
composer install

Edit the dotenv file

cp .env.example .env

Next, copy your Authy API Key from the Authy Dashboard and set the API_KEY variable in your .env file.

Install PHP, Composer, Laravel and MySQL.

        Account Security ConsoleからAPIキーを入力し、オプションでポートを変更します。


        Account Security ConsoleからAPIキーを入力し、オプションでポートを変更します。

        Migrate and launch the PHP Verify quickstart


        php artisan key:generate
        php artisan migrate
        php artisan serve --port 8081

        Assuming your API Key is correctly entered and the command above executed correctly, you'll soon get a message that the app is up!

        Use the PHP Phone Verification Demo

        Keeping your phone at your side, vist the Phone Verification page of the demo at http://localhost:8081/verify/

        Country Code(国コード)およびPhone Number(電話番号)を入力し、「SMS」または「CALL」(音声通話)どちらのチャンネルに検証をリクエストするか選択します。 最後に、青い「Request Verification(検証をリクエスト)」ボタンをクリックして待ちます。

        検証はすぐに終わります。 検証トークンを読み上げる音声通話がかかってくるか、トークンの記載されたSMSが受信されます。 音声通話をリクエストしていた場合、追加のセキュリティー機構として、(電話機のプッシュボタンで番号使用する)やり取りが発生する場合があります。


              いずれの方法でも、パスコードがリクエストされます。 トークンを検証入力フォームに入力し、「Verify Phone(電話番号を検証)」をクリックします。





                    And with that, your demo app is protected with Twilio's Verify phone verification! You can now log out to try the other channel.


                    Your demo app is now keeping hordes of fraudulent users from registering with your business and polluting the database. Next, you should check out all of the variables and options available to you in the Verify API Reference. Also, for protecting your customers in an ongoing manner (with this same codebase) try the PHP Authy Two-Factor Authentication Quickstart.

                    After that, take a stroll through the Docs for more Account Security demos and tutorials - as well as sample web applications using all of Twilio's products. Encore!

                    Rate this page:


                    誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。