TwilioDevEd / Eta Notifications Laravel
ETA Notifications for PHP - Laravel
ETA notifications implementation with PHP - Laravel and Twilio.
Run the application
-
Clone the repository and
cd
into it. -
Install the application dependencies with Composer
$ composer install
-
The application uses PostgreSQL as 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 eta_notifications
-
Copy the sample configuration file and edit it to match your configuration.
$ cp .env.example .env
You can find your TWILIO_ACCOUNT_SID
and TWILIO_AUTH_TOKEN
under
your
Twilio Account Settings.
You can buy Twilio phone numbers at Twilio numbers
TWILIO_NUMBER
should be set to the phone number you purchased above.
-
Generating an
APP_KEY
:$ php artisan key:generate
-
Running the migrations:
$ php artisan migrate
-
Modifying the seed data:
We have provided a name and phone number as example in the seed data. In order for the application to send sms notifications, you must edit this seed data providing a valid phone number where you want to receive the sms notifications.
In order to do this, you must modify this file that is located at:
project-root/database/seeds/OrdersTableSeeder.php
-
Seeding the database:
$ php artisan db:seed
-
Expose your application to the wider internet using ngrok. You can look here for more details. This step is important because the application won't work as expected if you run it through the localhost.
$ ngrok http 8000
-
Running the application using Artisan.
$ php artisan serve
Now you can access the application at your ngrok subdomain that should look
something like this: http://<subdomain>.ngrok.io
Exposing the Application to the Wider Internet
If you want your application to be accessible from the internet, you can either forward the necessary ports in your router, or use a tool like ngrok that will expose your local host to the internet.
You can read this blog for more details on how to use ngrok, but if you are using version 2.x, exposing a specific port should be easily done with the following command:
$ ngrok http 8000
Dependencies
This application uses this Twilio helper library:
Running the tests
-
Running at the top-level directory:
$ phpunit
If you don't have phpunit installed on your system, you can follow these instructions to install it.