0% found this document useful (0 votes)
5 views

PROJECT 3 POSTMAN

The project report details the development of a Task Manager Application using Laravel, focusing on creating a REST API for task management with features such as user authentication, CRUD operations, and task categorization. The application will utilize Laravel Sanctum for secure authentication and will be tested using Postman to ensure functionality and performance. The report outlines the methodology, technology stack, and implementation steps, culminating in a robust backend solution for managing tasks efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PROJECT 3 POSTMAN

The project report details the development of a Task Manager Application using Laravel, focusing on creating a REST API for task management with features such as user authentication, CRUD operations, and task categorization. The application will utilize Laravel Sanctum for secure authentication and will be tested using Postman to ensure functionality and performance. The report outlines the methodology, technology stack, and implementation steps, culminating in a robust backend solution for managing tasks efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

PROJECT REPORT

“Laravel Task Manager App using Rest API and POSTMAN”

ABSTRACT

This project involves building a Task Manager Application using Laravel, a popular PHP framework, to
provide a robust backend for managing tasks via a REST API. The API will be tested using Postman, ensuring
seamless CRUD (Create, Read, Update, Delete) operations.

Key Features
 User Authentication: Secure login and registration using Laravel Sanctum.

 Task Management: Users can create, update, delete, and retrieve tasks.

 Task Categorization: Tasks can be labeled with priorities or categories.

 API Development: RESTful routes, controllers, and resourceful responses.

 Postman Testing: API endpoints will be tested and validated using Postman.

Technology Stack
 Backend: Laravel (PHP)

 Database: MySQL

 Authentication: Laravel Sanctum

 API Testing: Postman


.
OBJECTIVE

The primary objective of this project is to develop a Task Manager Application using Laravel, a PHP
framework, to efficiently manage tasks through a REST API. The API will be designed following best
practices for security, scalability, and performance. Postman will be used for testing and validation to ensure
smooth CRUD (Create, Read, Update, Delete) operations.

 Develop a Secure and Scalable API:


 Implement a RESTful API using Laravel to handle task management.

 Ensure modularity and clean coding practices for easy maintenance.

 Implement User Authentication and Authorization:


 Secure user authentication using Laravel Sanctum for API token-based authentication.

 Implement role-based access control (RBAC) to restrict unauthorized actions .

 Enable Full CRUD Operations for Task Management:


 Users should be able to Create, Read, Update, and Delete tasks.

 Each task should have attributes like title, description, status, priority, and due date.

 Task Categorization and Filtering:


 Allow users to categorize tasks based on priority or labels.

 Implement sorting and filtering features for better task organization.

 Develop RESTful API Endpoints:


 Structure the API with proper resourceful controllers and routes.

 Follow REST API standards, ensuring clear request and response handling.

 Ensure Efficient API Testing with Postman:


 Validate API functionality using Postman to test all endpoints.

 Ensure proper error handling, status codes, and responses for robustness.

 Database Management Using MySQL:


 Design a well-structured database schema to store users and tasks efficiently.

 Implement migrations and seeders for easy database setup and testing.
Optimize API Performance and Security:
 Use Laravel Eloquent ORM for database interactions.
 Implement middleware for security and validation of API requests

INTRODUCTION

In today's fast-paced digital environment, efficient task management is essential for personal productivity and
team collaboration. A Task Manager Application provides a structured way to create, track, and manage tasks
effectively. This project focuses on developing a Task Manager App using Laravel, a powerful PHP framework
known for its elegant syntax, robust features, and scalability.
This application will expose a REST API to handle task management functionalities, including user
authentication, task creation, updating, deletion, and categorization. The API will follow RESTful principles to
ensure structured communication between the frontend (or clients) and the backend.
To validate and test the API, Postman will be used as a testing tool. Postman allows developers to send API
requests, inspect responses, and ensure the API is functioning correctly. This approach ensures smooth
development, debugging, and optimization of the API.
Laravel is chosen as the backend framework due to its:
 MVC Architecture, which ensures code maintainability and separation of concerns.
 Eloquent ORM, which simplifies database interactions.
 Built-in Authentication System, which provides secure API authentication via Laravel Sanctum.
 Middleware Support, which allows efficient request validation and security handling.
Project Scope
This Task Manager App will include features such as:
✅ User Registration & Login (API token-based authentication with Laravel Sanctum)
✅ Task CRUD Operations (Create, Read, Update, Delete tasks)
✅ Task Categorization (Priorities, labels, or custom categories)
✅ REST API Development (Well-structured endpoints using Laravel controllers)
✅ API Testing using Postman (Ensuring endpoint correctness and security)
METHODOLOGY

1. Planning & Requirement Analysis


Define the core functionalities of the Task Manager App.
Identify user roles (e.g., authenticated users vs. guests).
Outline required API endpoints and their expected behavior.
Design the database schema to manage users and tasks efficiently.

2. Environment Setup & Technology Stack


Install Laravel Framework and set up a new project.
Configure MySQL database and establish a connection with Laravel.
Set up Laravel Sanctum for API authentication.
Install necessary dependencies (e.g., Laravel Passport for OAuth, or additional security packages).

3. Database Design & Migrations


Define database tables for users and tasks using Laravel migrations.
Implement Eloquent relationships (e.g., one-to-many between users and tasks).
Use seeders and factories to generate sample data for testing.
Example Database Schema:
📌 Users Table
id (Primary Key)
name
email
password
created_at / updated_at
📌 Tasks Table
id (Primary Key)
user_id (Foreign Key → users)
title
description
status (pending, in-progress, completed)
priority (low, medium, high)
due_date
created_at / updated_at

4. API Development (RESTful Architecture)


Create RESTful routes using Laravel's routes/api.php.
Develop Controllers to handle requests (TaskController, AuthController).
Implement Middleware for request validation and security.
Use Form Requests to validate user inputs.
Example API Routes:

5. Authentication & Security


Implement Laravel Sanctum for secure API authentication.
Use JWT (JSON Web Token) or API tokens for user authentication.
Apply role-based access control (RBAC) if needed.
Use middleware for protecting API routes from unauthorized access.

6. API Testing with Postman


Use Postman to send API requests and validate responses.
Test edge cases, such as invalid inputs, unauthorized access, and incorrect data.
Verify CRUD operations to ensure smooth task management.
Check status codes (200, 201, 400, 401, 404, 500) for proper API response handling .

7. Deployment & Documentation


 Deploy the Laravel application on, AWS Heroku or DigitalOcean,.
 Configure production database and environment settings.
 Generate API documentation using tools like Swagger or Laravel API Resources
CODE: -

1. Setup Laravel Project

First, create a new Laravel project and install dependencies:

sh

CopyEdit

composer create-project --prefer-dist laravel/laravel TaskManager

cd TaskManager

composer require laravel/sanctum

php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"

php artisan migrate

Enable Sanctum middleware in app/Http/Kernel.php:

php

CopyEdit

use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;

protected $middlewareGroups = [

'api' => [

EnsureFrontendRequestsAreStateful::class,

'throttle:api',

\Illuminate\Routing\Middleware\SubstituteBindings::class,

],

];

Run migrations:

sh

CopyEdit

php artisan migrate

2. Create Models and Migrations

User Model (app/Models/User.php)

Modify the User model to use Sanctum:


php

CopyEdit

use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable

use HasApiTokens, Notifiable;

Task Model (app/Models/Task.php)

php

CopyEdit

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

use Illuminate\Database\Eloquent\Model;

class Task extends Model

use HasFactory;

protected $fillable = ['user_id', 'title', 'description', 'status', 'priority', 'due_date'];

public function user()

return $this->belongsTo(User::class);

Task Migration (database/migrations/xxxx_xx_xx_create_tasks_table.php)

php

CopyEdit

use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;
class CreateTasksTable extends Migration

public function up()

Schema::create('tasks', function (Blueprint $table) {

$table->id();

$table->foreignId('user_id')->constrained()->onDelete('cascade');

$table->string('title');

$table->text('description');

$table->enum('status', ['pending', 'in-progress', 'completed'])->default('pending');

$table->enum('priority', ['low', 'medium', 'high'])->default('medium');

$table->date('due_date')->nullable();

$table->timestamps();

});

public function down()

Schema::dropIfExists('tasks');

Run migrations:

sh

CopyEdit

php artisan migrate

3. API Routes (routes/api.php)

php

CopyEdit

use App\Http\Controllers\AuthController;

use App\Http\Controllers\TaskController;

use Illuminate\Support\Facades\Route;

Route::post('/register', [AuthController::class, 'register']);


Route::post('/login', [AuthController::class, 'login']);

Route::middleware('auth:sanctum')->group(function () {

Route::post('/logout', [AuthController::class, 'logout']);

Route::apiResource('tasks', TaskController::class);

});

4. Authentication Controller (app/Http/Controllers/AuthController.php)

php

CopyEdit

namespace App\Http\Controllers;

use App\Models\User;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Hash;

use Illuminate\Validation\ValidationException;

class AuthController extends Controller

public function register(Request $request)

$request->validate([

'name' => 'required|string|max:255',

'email' => 'required|string|email|unique:users',

'password' => 'required|string|min:6',

]);

$user = User::create([

'name' => $request->name,

'email' => $request->email,

'password' => Hash::make($request->password),

]);

return response()->json(['message' => 'User registered successfully'], 201);


}

public function login(Request $request)

$request->validate([

'email' => 'required|email',

'password' => 'required',

]);

$user = User::where('email', $request->email)->first();

if (!$user || !Hash::check($request->password, $user->password)) {

throw ValidationException::withMessages(['email' => 'Invalid credentials']);

return response()->json(['token' => $user->createToken('API Token')->plainTextToken]);

public function logout(Request $request)

$request->user()->tokens()->delete();

return response()->json(['message' => 'Logged out successfully']);

5. Task Controller (app/Http/Controllers/TaskController.php)

php

CopyEdit

namespace App\Http\Controllers;

use App\Models\Task;

use Illuminate\Http\Request;

class TaskController extends Controller


{

public function index()

return response()->json(auth()->user()->tasks);

public function store(Request $request)

$request->validate([

'title' => 'required|string|max:255',

'description' => 'required|string',

'status' => 'in:pending,in-progress,completed',

'priority' => 'in:low,medium,high',

'due_date' => 'date|nullable',

]);

$task = auth()->user()->tasks()->create($request->all());

return response()->json($task, 201);

public function show(Task $task)

if ($task->user_id !== auth()->id()) {

return response()->json(['error' => 'Unauthorized'], 403);

return response()->json($task);

public function update(Request $request, Task $task)

if ($task->user_id !== auth()->id()) {

return response()->json(['error' => 'Unauthorized'], 403);


}

$request->validate([

'title' => 'string|max:255',

'description' => 'string',

'status' => 'in:pending,in-progress,completed',

'priority' => 'in:low,medium,high',

'due_date' => 'date|nullable',

]);

$task->update($request->all());

return response()->json($task);

public function destroy(Task $task)

if ($task->user_id !== auth()->id()) {

return response()->json(['error' => 'Unauthorized'], 403);

$task->delete();

return response()->json(['message' => 'Task deleted successfully']);

6. Testing with Postman

 Register User (POST /api/register)

json

CopyEdit

"name": "John Doe",

"email": "[email protected]",
"password": "password123"

 Login (POST /api/login) → Returns API token

 Create Task (POST /api/tasks, add token in Authorization)

 Get Tasks (GET /api/tasks, add token in Authorization)

 Update Task (PUT /api/tasks/{id})

 Delete Task (DELETE /api/tasks/{id})

7. Running the Application

Start the Laravel server:

sh

CopyEdit

php artisan serve

OUTPUT
Conclusion
The Laravel Task Manager App using REST API and Postman successfully demonstrates how to build a secure,
scalable, and efficient backend for task management. This project provides user authentication, task creation,
updating, deletion, and retrieval using Laravel's powerful features, including Sanctum for API authentication
and Eloquent ORM for database interactions.
Through Postman testing, we validated API endpoints, ensuring proper error handling, authentication security,
and data consistency. This project serves as a solid foundation for developing a full-fledged task management
system, which can be extended with a frontend (React, Vue, or Angular) or integrated with mobile applications.

You might also like