A simple To-Do list API built with Laravel.
Follow these steps to get the application up and running.
- MySQL Server
- Redis Server
- PHP 8.3
- PHP Composer
-
Create MySQL and Redis servers
Ensure that you have MySQL and Redis servers set up and running.
-
Copy
.env
filecp .env.example .env
-
Update
.env
fileUpdate the
.env
file with your environment-specific details, such as database credentials and Redis connection. -
Install Dependencies
composer install
-
Generate Application Key
php artisan key:generate
-
Run Database Seeder
php artisan db:seed
-
Serve site with herd or valet or nginx
herd domain test herd link laravel-todolist-api herd secure --site=laravel-todolist-api
Follow official documentation for nginx configuration and valet.
You can test the application using the following HTTP requests:
Request:
POST https://laravel-todolist-api.test/api/register
Content-Type: application/json
{
"name": "user",
"email": "user@user.com",
"password": "password",
"password_confirmation": "password"
}
Request:
POST https://laravel-todolist-api.test/api/login
Content-Type: application/json
{
"email": "user@user.com",
"password": "password"
}
Request:
POST https://laravel-todolist-api.test/api/todo
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
{
"title": "todo title",
"description": "todo description",
"completed": "0"
}
Request:
GET https://laravel-todolist-api.test/api/todo
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Request:
GET https://laravel-todolist-api.test/api/todo/1
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
{
"completed": 1
}
Request:
PATCH https://laravel-todolist-api.test/api/todo/1
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
{
"title": "todo title",
"description": "todo description",
"completed": "1"
}
Request:
DELETE https://laravel-todolist-api.test/api/todo/1
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Replace YOUR_ACCESS_TOKEN
with the actual token obtained during login for authorization.