-
Install Composer
-
Install Postman
-
Use Composer to install the required dependencies by navigating to the root directory of the cloned repository and run the following command inside the Terminal:
composer install
- Rename the ".env.example" file in the root directory to ".env" for "apigateway", "authorapi" and "bookapi".
- Generate 3 application keys using Random string generator:
- Change the Number of Strings to 3, Length to 32 characters and click Generate.
- Copy the 3 keys from Output and initialize the APP_KEY= inside the ".env" files for "apigateway", "authorapi" and "booksapi".
- Generate 2 additional keys using Random string generator:
- Change the Number of Strings to 2, Length to 32 characters and click Generate.
- Copy the first key from Output and initialize the AUTHORS_SERVICE_SECRET= inside the ".env" file for "apigateway" and also replace the ACCEPTED_SECRETS= with the copied key for "authorapi".
- Copy the second key from Output and initialize the BOOKS_SERVICE_SECRET= inside the ".env" file for "apigateway" and also replace the ACCEPTED_SECRETS= with the copied key for "booksapi".
- Create the database file for MySql:
- create a file database "apigateway" .
- create a file database "authorapi" .
- create a file database "bookapi" .
-
Initialize the database to add fake data:
- Open the Terminal instance and navigate to the root directory of "authorapi" and run the following commands:
php artisan migrate php artisan db:seed
- Open the second Terminal instance and navigate to the root directory of "bookapi" and run the following commands:
php artisan migrate php artisan db:seed
- Open the third Terminal instance and navigate to the root directory of "apigateway" and run the following commands:
php artisan migrate php artisan passport:install
- Open the Terminal instance and navigate to the root directory of "authorapi" and run the following commands:
-
The "php artisan passport:install" command creates two clients in the "apigateway" database table 'oauth_clients' Personal access client and Password grant client which is to be used to get the access token for the users.
-
Run three servers, each for "authorapi", "bookapi" and "apigateway":
- Open the fourth Terminal and navigate to the root directory of "authorapi" and run the following command:
php -S localhost:8000 -t public
- Open the fifth Terminal and navigate to the root directory of "bookapi" and run the following command:
php -S localhost:8001 -t public
- Open the sixth Terminal and navigate to the root directory of "apigateway" and run the following command:
php -S localhost:8002 -t public
- Open the fourth Terminal and navigate to the root directory of "authorapi" and run the following command:
-
Copy the Password grant client Id and Client Secret from the third Terminal instance and make a POST request using POSTMAN to fetch the access_token:
API docs are available here: https://documenter.getpostman.com/view/2791867/UyxojQ8M