Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

TwilioDevEd/twiliochat-laravel

Repository files navigation

Important Notice

We intend to sunset the Programmable Chat API on July 25, 2022 to focus on the next generation of chat: the Twilio Conversations API. Find out about the EOL process. We have also prepared this Migration Guide to assist in the transition from Chat to Conversations.

twiliochat-laravel

Build Status

Laravel implementation of Twilio Chat

Run the application

  1. Clone the repository and cd into it

  2. Install the application's dependencies with Composer

    composer install
  3. Copy the sample configuration file and edit it to match your configuration

    cp .env.example .env

You can find your TWILIO_ACCOUNT_SID in your Twilio Account Settings. You need to create an API key that will give you a TWILIO_API_KEY and a TWILIO_API_SECRET. For that purpose click here.

For TWILIO_CHAT_SERVICE_SID you can click here, where you must create a Programmable Chat Service. When the service is created you'll have access to the service's SID.

  1. Generate an APP_KEY

    php artisan key:generate
  2. Run the application using Artisan

php artisan serve

Now you can access the application at http://localhost:8000.

Expose your localhost to the internet

If you want your chat application to be reachable publicly in the internet, you can use a service like ngrok.

  1. Expose the application to the wider Internet

    ngrok http 8000

It is artisan serve default behavior to use http://localhost:8000 when running the application. This means that the ip addresses where your app will be reachable on you local machine will vary depending on the operating system.

The most common scenario, is that your app will be reachable through address http://127.0.0.1:8000, and this is important because ngrok creates the tunnel using only that address. So, if http://127.0.0.1:8000 is not reachable in your local machine when you run the app, you must tell artisan to use an address, like this:

php artisan serve --host=127.0.0.1

Dependencies

This application uses this Twilio helper library

Run the tests

  1. Run at the top-level directory

    vendor/bin/phpunit

    If you don't have phpunit installed on your system, you can follow these instructions to install it.

  2. Run javascript tests

    cd public && npm install && npm test