Project URL: https://ei5czcnukfdljefgeiqwmjgygq0utyvh.cell-1-lambda-url.us-east-1.on.aws/login
Email: admin@demo.com
Password: password
Swagger APIs Documentation: https://ei5czcnukfdljefgeiqwmjgygq0utyvh.cell-1-lambda-url.us-east-1.on.aws/api/documentation
The project above allows for user to: List, Get, Create, Update and Delete Users using api endpoints below
API Endpoints
- `GET /users`: Returns a list of all users.
- `GET /users/{id}`: Returns a specific user by ID.
- `POST /users`: Creates a new user.
- `PUT /users/{id}`: Updates an existing user by ID.
- `DELETE /users/{id}`: Deletes a user by ID.
This repository contains a RESTful API project built with https://laravel.com/ and utilizes https://redis.io/ for queue management to process background jobs. The application is deployed using https://vapor.laravel.com/ on the https://aws.amazon.com/. The API endpoints provided include user-related functionalities, and MySQL is used as the database to store user data.
Follow these steps to set up and install the project locally:
-
Clone the repository from GitHub:
git clone https://github.com/Nderi12/Laravel-Vapor-RESTful-API.git
-
Install the project dependencies:
composer install
-
Create a new
.env
file:cp .env.example .env
-
Generate a new application key:
php artisan key:generate
-
Create a new MySQL database and update the
.env
file with the database credentials:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_database_username DB_PASSWORD=your_database_password
-
Run the database migrations:
php artisan migrate
In this project, we intend to send every new user an invitation. The process will be handled using laravel’s package https://github.com/predis/predis. The project is configured to use redis as our queue worker
-
Update the
.env
file to use Redis as the queue driver:QUEUE_CONNECTION=redis
Start the Redis server using the command:
sudo service redis-server start
-
Configure SMTP settings for sending emails:
Open the
.env
file and update the following SMTP settings:MAIL_MAILER=smtp MAIL_HOST=your-smtp-host MAIL_PORT=your-smtp-port MAIL_USERNAME=your-smtp-username MAIL_PASSWORD=your-smtp-password MAIL_ENCRYPTION=ssl
-
Start the Queue Worker:
Run the following command to start processing background jobs:
php artisan queue:work
Run the laravel tests:
php artisan test
The Swagger OpenAPIs documentation is available at:
https://{{base_url}}/api/documentation
This project is deployed using https://vapor.laravel.com/ on the AWS infrastructure. Follow these steps to deploy the application using Laravel Vapor:
-
AWS Setup:
- Navigate to your AWS security credentials and get the Access Key ID and Secret Access Key.
-
Laravel Vapor Setup:
- Create a team in your Laravel Vapor account.
- Link your AWS account with Vapor by providing the Access Key ID and Secret Access Key.
-
In the Laravel Project:
- Run the command
vapor login
and provide your Vapor account credentials.
- Run the command
-
Initializing Vapor Project:
- Run the command below to configure the project settings, select your region, and install the core package (if not already installed). This will generate the
vapor.yaml
file in the root directory.
vapor init
- Run the command below to configure the project settings, select your region, and install the core package (if not already installed). This will generate the
-
Adding Database:
- Run the command
vapor database my-test-database --dev
to create a public development database. - Update the
vapor.yaml
database hook with the appropriate database name.
- Run the command
-
Deployment:
- Run the command
vapor deploy specify_environment
to deploy your application to AWS Lambda and frontend assets to CloudFront (AWS CDN). - After a successful deploy, obtain the Environment URL and update the
.env
file'sL5_SWAGGER_CONST_HOST
variable.
- Run the command
-
Accessing API Documentation:
- Deploy the application again using
vapor deploy specify_environment
. - Access the API documentation at the URL:
https://{{project_url}}/api/documentation
.
- Deploy the application again using
- The project utilizes Laravel Vapor for efficient deployment on AWS infrastructure.
- Redis is used for queue management to process background jobs.
- MySQL is used to store user data.
- The
.env
file must be properly configured with the necessary environment-specific values.
For any additional information or support, please refer to the official Laravel and Laravel Vapor documentation.