This is a GitHub template for creating other Twilio sample/template apps. It contains a variety of features that should ideally be included in every Twilio sample app. You can use GitHub's repository template functionality to create a copy of this.
Implementations in other languages:
.NET | Java | Python | PHP | Node |
---|---|---|---|---|
TBD | TBD | TBD | TBD | Done |
This application is only a barebones PHP application using Laravel. Whenever, possible we should be using this. However, if you are using a framework like Symfony, Lumen or similar that comes with their own standardized application structure, you should try to merge these by using the same README
structure and test coverage, configuration etc. as this project.
- PHP web server using Laravel
- Basic web user interface using Blade for templating and Bootstrap for UI
- Unit tests using PHPUnit
- End to End UI testing using Dusk
- Automated CI testing using GitHub Actions
- Linting and formatting using PHP Coding Standards Fixer
- Project specific environment variables using
.env
files. - One click deploy buttons for Heroku.
- Create a copy using GitHub's repository template functionality
- Update the
README.md
,composer.json
andapp.json
with the respective values. - Build your app as necessary while making sure the tests pass.
- Publish your app to GitHub
- PHP >= 7.2.5 and composer
- Node.js
- A Twilio account - sign up
This application should give you a ready-made starting point for writing your own application. Before we begin, we need to collect all the config values we need to run the application:
Config Value | Description |
---|---|
Account Sid | Your primary Twilio account identifier - find this in the Console. |
Auth Token | Used to authenticate - just like the above, you'll find this here. |
Phone number | A Twilio phone number in E.164 format - you can get one here |
After the above requirements have been met:
-
Clone this repository and
cd
into itgit clone [email protected]:twilio-labs/sample-template-laravel.git cd sample-template-laravel
-
Install PHP dependencies
composer install
-
Set your environment variables
cp .env.example .env
See Twilio Account Settings to locate the necessary environment variables.
-
Generate application key
php artisan key:generate
-
Install Node dependencies
npm install
-
Build the frontend assets
npm run dev
-
Run the application
php artisan serve
-
Navigate to http://localhost:8000
That's it!
You can run the Unit and Feature tests locally by typing:
php artisan test
-
To run the Browser tests you first need to install the latest version of ChromeDriver for your OS
php artisan dusk:chrome-driver
-
Copy the
.env.dusk.testing
to.env.dusk.local
cp .env.dusk.testing .env.dusk.local
-
Then you can run the tests by typing:
php artisan dusk
Note: You need to have the dev server running or use
php artisan dusk:serve
instead
Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.
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.
Service | |
---|---|
Heroku |
- GitHub's repository template functionality
This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.
No warranty expressed or implied. Software is as is.