Welcome to the CRUD API documentation Laravel application. This API allows you to Create, Read, Update, and Delete user records.
Before you start, make sure you have the following prerequisites installed on your system:
- PHP (>= 7.4)
- Composer
- Laravel (>= 8.x)
- Database (e.g., MySQL, PostgreSQL)
-
Clone this repository:
git clone https://github.com/GoodnewsPerfect/HNGx-task2 cd HNGx-task2
-
Install PHP dependencies using Composer:
composer install
-
Create a .env file by copying the .env.example file and configure your database settings:
cp .env.example .env
Configure the database config variables as follows:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD=
-
Run the migrations:
php artisan migrate
-
Start the development server:
php artisan serve
Laravel API is now up and running on {127.0.0.1:8000} which is the base url!
The API uses JSON for both requests and responses. The following table describes the JSON format for the requests and responses:
Requests | Response |
---|---|
POST /api | 201 Created with the newly created user in the response body |
GET /api | 200 OK with an array of users in the response body. |
GET /api/{id} | 200 OK with the user with the specified id in the response body. |
PUT /api/{id} | 200 OK with the updated user in the response body. |
DELETE /api/{id} | 204 No Content |