This repository is the complete example for the accompanying post at: Community Repository
This branch is the introduction branch. For a more complete example of the code please checkout to the end-tutorial
branch.
Table of Contents
- A phone number
- A Vonage account
- Docker
- Ngrok
Because this project will be making use of a mobile app built in React Native, along with authentication being required, JWT will be generated. So certificates need to be generated in other to make the JWT tokens. In the root of your project, run the following three commands:
mkdir API/var/jwt
openssl genpkey -out API/var/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
openssl pkey -in API/var/jwt/private.pem -out API/var/jwt/public.pem -pubout
Making a phone call with Vonage, requires a virtual phone number with a webhook to log the events that happen when a phone call is made, answered, rejected, or ended. For the tutorial, ngrok is the service of choice to expose the application to the Internet. Install ngrok, and run the following command:
ngrok http 8080
Make sure to copy your ngrok HTTPS url as you'll need this later when configuring the project.
Copy or rename .env.dist
to .env
.
First fields to be updated are the values for your database credentials and config. An example is shown below, but please use more secure credentials.
DATABASE_URL=mysql://db_user:db_password@mysql:3306/on_call?serverVersion=8.0
MYSQL_DATABASE=on_call
MYSQL_USER=db_user
MYSQL_PASSWORD=db_password
MYSQL_ROOT_PASSWORD=root_password
JWT_PASSPHRASE=<your jwt passphrase>
cd Docker
docker-compose up -d
composer install
php bin/console doctrine:migrations:migrate
php bin/console doctrine:fixtures:load
Make a POST request to <ngrok Url>/api/login_check
replacing the <
and >
with your ngrok url. The content type of the post request needs to be application/json
and the body of the request needs to be similar to the following:
{
"username": "[email protected]",
"password": "test_pass"
}
On a successful request, you'll receive a JWT token in the response.
In a new Terminal run the following two commands:
cd MobileApp
npm install
expo start
In the interest of fostering an open and welcoming environment, we strive to make participation in our project and our community a harassment-free experience for everyone. Please check out our Code of Conduct in full.
We ❤️ contributions from everyone! Check out the Contributing Guidelines for more information.
This project is subject to the MIT License