An example application implementing an automated phone line using Twilio and Laravel.
-
Clone the repository and
cd
into it. -
Install the application's dependencies with Composer
composer install
-
The application uses PostgreSQL as the persistence layer. If you don't have it already, you should install it. The easiest way is by using Postgres.app.
-
Create a database.
createdb ivr_recording
-
Copy the sample configuration file and edit it to match your configuration.
cp .env.example .env
You'll need to set
DB_HOST
,DB_DATABASE
,DB_USERNAME
, andDB_PASSWORD
. You can often leaveDB_USERNAME
andDB_PASSWORD
empty.DB_HOST
should belocalhost
if you're running the DB in your own machine. -
Generate an
APP_KEY
:php artisan key:generate
-
Run the migrations:
php artisan migrate
-
Load seed data:
php artisan db:seed
-
Run the application using Artisan.
php artisan serve
-
Expose the application to the wider Internet using ngrok
ngrok http 8000
-
Provision a number under the Manage Numbers page on your account. Set the voice URL for the number to
http://<your-ngrok-subdomain>.ngrok.io/ivr/welcome
. -
Grab your phone and call your newly-provisioned number!
This application uses this Twilio helper library:
-
Configure a test database in
.env.test
. -
Run the database migrations for the test database
APP_ENV=testing php artisan migrate
-
Run at the top-level directory:
phpunit --coverage-text
If your PHP installation doesn't have xdebug
support then simply run
the tests without coverage reporting:
phpunit