Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit bbf1fd7

Browse files
author
Carlos Villavicencio
committed
Add Makefile and update readme template
1 parent 4c1fd75 commit bbf1fd7

File tree

3 files changed

+99
-94
lines changed

3 files changed

+99
-94
lines changed

.github/workflows/laravel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [ master ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ master, next ]
88

99
jobs:
1010
build:

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
UNAME := $(shell uname)
2+
install:
3+
mkdir -p database
4+
touch database/database.sqlite
5+
touch database/database-test.sqlite
6+
composer install
7+
php artisan key:generate --force
8+
php artisan migrate --force
9+
php artisan db:seed --force
10+
11+
serve-setup:
12+
php artisan serve --host=127.0.0.1
13+
open-browser:
14+
python3 -m webbrowser "http://127.0.0.1:8000";
15+
serve: open-browser serve-setup
16+
17+
test:
18+
php artisan migrate --database=testing --force
19+
vendor/bin/phpunit

readme.md

Lines changed: 79 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,145 @@
1+
<a href="https://www.twilio.com">
2+
<img src="https://static0.twilio.com/marketing/bundles/marketing/img/logos/wordmark-red.svg" alt="Twilio" width="250" />
3+
</a>
4+
15
# Airtng App: Part 1 - Workflow Automation with Twilio - Laravel
26

37
![](https://github.com/TwilioDevEd/airtng-laravel/workflows/Laravel/badge.svg)
48

5-
69
> We are currently in the process of updating this sample template. If you are encountering any issues with the sample, please open an issue at [github.com/twilio-labs/code-exchange/issues](https://github.com/twilio-labs/code-exchange/issues) and we'll try to help you.
710
11+
## About
12+
813
Learn how to automate your workflow using Twilio's REST API and Twilio SMS. This example app is a vacation rental site where the host can confirm a reservation via SMS.
914

1015
[Read the full tutorial here](https://www.twilio.com/docs/tutorials/walkthrough/workflow-automation/php/laravel)!
1116

12-
## Run the application
17+
Implementations in other languages:
1318

14-
1. Clone the repository and `cd` into it.
19+
| .NET | Java | Python | Ruby | Node |
20+
| :--- | :--- | :----- | :-- | :--- |
21+
| [Done](https://github.com/TwilioDevEd/airtng-csharp-dotnet-core) | [Done](https://github.com/TwilioDevEd/airtng-servlets) | [Done](https://github.com/TwilioDevEd/airtng-flask) | TBD | [Done](https://github.com/TwilioDevEd/airtng-node) |
1522

16-
1. Install the application's dependencies with [Composer](https://getcomposer.org/)
23+
## Set up
1724

18-
```bash
19-
$ composer install
20-
```
21-
1. The application uses [sqlite3](https://www.sqlite.org/) as the persistence layer. If you
22-
don't have it already, you should install it.
25+
### Requirements
2326

24-
1. Create an empty database file.
27+
- [PHP >= 7.2.5](https://www.php.net/) and [composer](https://getcomposer.org/)
28+
- A Twilio account - [sign up](https://www.twilio.com/try-twilio)
29+
- The application uses [sqlite3](https://www.sqlite.org/) as the persistence layer. If you don't have it already, you should install it.
2530

26-
```bash
27-
$ touch database/database.sqlite
28-
```
31+
### Twilio Account Settings
2932

30-
1. Copy the sample configuration file and edit it to match your configuration.
33+
This application should give you a ready-made starting point for writing your own application.
34+
Before we begin, we need to collect all the config values we need to run the application:
3135

32-
```bash
33-
$ cp .env.example .env
34-
```
36+
| Config&nbsp;Value | Description |
37+
| :---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- |
38+
| Account&nbsp;Sid | Your primary Twilio account identifier - find this [in the Console](https://www.twilio.com/console). |
39+
| Auth&nbsp;Token | Used to authenticate - [just like the above, you'll find this here](https://www.twilio.com/console). |
40+
| Phone&nbsp;number | A Twilio phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164) - you can [get one here](https://www.twilio.com/console/phone-numbers/incoming) |
3541

36-
You can find your `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` under
37-
your
38-
[Twilio Account Settings](https://www.twilio.com/user/account/settings).
39-
You can buy a Twilio phone number here [Twilio numbers](https://www.twilio.com/user/account/phone-numbers/search)
40-
`TWILIO_NUMBER` should be set according to the phone number you purchased above.
42+
### Local development
4143

42-
1. Generate an `APP_KEY`.
44+
After the above requirements have been met:
4345

44-
```bash
45-
$ php artisan key:generate
46-
```
46+
1. Clone this repository and `cd` into it
4747

48-
1. Run the migrations.
48+
```bash
49+
git clone [email protected]:TwilioDevEd/airtng-laravel.git
50+
cd airtng-laravel
51+
```
4952

50-
```bash
51-
$ php artisan migrate
52-
```
53+
1. Install PHP dependencies
5354

54-
1. Load the seed data.
55+
```bash
56+
make install
57+
```
5558

56-
```bash
57-
$ php artisan db:seed
58-
```
59+
1. Set your environment variables
60+
61+
```bash
62+
cp .env.example .env
63+
```
64+
65+
See [Twilio Account Settings](#twilio-account-settings) to locate the necessary environment variables.
5966

6067
1. Expose the application to the wider Internet using [ngrok](https://ngrok.com/)
6168

6269
```bash
6370
$ ngrok http 8000
6471
```
65-
Once you have started ngrok, update your Twilio number sms URL
66-
settings to use your ngrok hostname. It will look something like
67-
this:
72+
73+
Once you have started ngrok, update your Twilio number sms URL settings to use your ngrok hostname. It will look something like this:
6874

6975
```
7076
http://<your-ngrok-subdomain>.ngrok.io/reservation/incoming
7177
```
7278

73-
1. Configure Twilio to call your webhooks.
79+
6. Configure Twilio to call your webhooks.
7480

75-
You will also need to configure Twilio to send requests to your application
76-
when sms are received.
81+
You will also need to configure Twilio to send requests to your application when sms are received.
7782

78-
You will need to provision at least one Twilio number with sms capabilities
79-
so the application's users can make property reservations. You can buy a number [right
80-
here](https://www.twilio.com/user/account/phone-numbers/search). Once you have
81-
a number you need to configure it to work with your application. Open
82-
[the number management page](https://www.twilio.com/user/account/phone-numbers/incoming)
83-
and open a number's configuration by clicking on it.
83+
You will need to provision at least one Twilio number with sms capabilities so the application's users can make property reservations. You can buy a number [right here](https://www.twilio.com/user/account/phone-numbers/search). Once you have a number you need to configure it to work with your application. Open [the number management page](https://www.twilio.com/user/account/phone-numbers/incoming) and open a number's configuration by clicking on it.
8484

85-
Remember that the number where you change the sms webhooks must be the same one you set on
86-
the `TWILIO_NUMBER` environment variable.
85+
Remember that the number where you change the sms webhooks must be the same one you set on the `TWILIO_NUMBER` environment variable.
8786

8887
![Configure Messaging](webhook.png)
8988

90-
For this application, you must set the voice webhook of your number so that it
91-
looks something like this:
89+
For this application, you must set the voice webhook of your number so that it looks something like this:
9290

9391
```
9492
http://<your-ngrok-subdomain>.ngrok.io/reservation/incoming
9593
```
9694

9795
And in this case set the `POST` method on the configuration for this webhook.
9896

99-
1. Run the application using Artisan.
97+
1. Run the application
10098

101-
```bash
102-
$ php artisan serve
103-
```
99+
```bash
100+
make serve
101+
```
104102

105-
It is `artisan serve` default behaviour to use `http://localhost:8000` when
106-
the application is run. This means that the ip addresses where your app will be
107-
reachable on you local machine will vary depending on the operating system.
103+
1. Navigate to [http://localhost:8000](http://localhost:8000)
108104

109-
The most common scenario is that your app will be reachable through address
110-
`http://127.0.0.1:8000`. This is important because ngrok creates the
111-
tunnel using only that address. So, if `http://127.0.0.1:8000` is not reachable
112-
in your local machine when you run the app, you must tell artisan to use this
113-
address. Here's how to set that up:
105+
That's it!
114106
115-
```bash
116-
$ php artisan serve --host=127.0.0.1
117-
```
107+
### Unit and Integration Tests
118108
119-
## Dependencies
109+
First, run the migrations for the testing database.
110+
```bash
111+
php artisan migrate --database=testing
112+
```
120113
121-
This application uses this Twilio helper library:
122-
* [twilio-php](https://github.com/twilio/twilio-php)
114+
You can run the Unit tests locally by typing:
115+
```bash
116+
vendor/bin/phpunit
117+
```
123118
124-
## Run the tests
119+
### Cloud deployment
125120
126-
1. Create an empty database file.
121+
Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.
127122
128-
```bash
129-
$ touch database/database-test.sqlite
130-
```
123+
Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.
131124
132-
1. Run the migrations.
125+
| Service | |
126+
| :-------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
127+
| [Heroku](https://www.heroku.com/) | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) |
133128
134-
```bash
135-
$ php artisan migrate --database=testing
136-
```
129+
## Resources
137130
138-
1. Run at the top-level directory.
131+
- The CodeExchange repository can be found [here](https://github.com/twilio-labs/code-exchange/).
139132
140-
```bash
141-
$ phpunit
142-
```
133+
## Contributing
143134
144-
or
135+
This template is open source and welcomes contributions. All contributions are subject to our [Code of Conduct](https://github.com/twilio-labs/.github/blob/master/CODE_OF_CONDUCT.md).
145136
146-
```bash
147-
$ vendor/bin/phpunit
148-
```
137+
## License
138+
139+
[MIT](http://www.opensource.org/licenses/mit-license.html)
149140
150-
If you don't have phpunit installed on your system, you can follow [these
151-
instructions](https://phpunit.de/manual/current/en/installation.html) to
152-
install it.
141+
## Disclaimer
153142
154-
## Meta
143+
No warranty expressed or implied. Software is as is.
155144
156-
* No warranty expressed or implied. Software is as is. Diggity.
157-
* The CodeExchange repository can be found [here](https://github.com/twilio-labs/code-exchange/).
158-
* [MIT License](http://www.opensource.org/licenses/mit-license.html)
159-
* Lovingly crafted by Twilio Developer Education.
145+
[twilio]: https://www.twilio.com

0 commit comments

Comments
 (0)