Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP OOP CRUD — Task Manager

Batch 12 | Module 7 Assignment

A complete task management application built with pure PHP OOP, Tailwind CSS, and Alpine.js. Demonstrates CRUD operations, database abstraction, MVC-style architecture, and modern frontend design.


Table of Contents


Project Overview

This project fulfills the Module 7 assignment requirements which covered:

  • Task 1: String & Array Manipulation (task1.php)
  • Task 2: Encapsulation — Employee Management (task2.php)
  • Task 3: Inheritance — Vehicle System (task3.php)

Beyond the assignment, a full-featured CRUD web application was built inside the app/ directory to demonstrate real-world application of all OOP concepts.


Features

  • Create, Read, Update, and Delete tasks
  • Task properties: title, description, status, priority
  • Search tasks by title or description
  • Dashboard with stat cards (Pending, In Progress, Completed)
  • Flash messages for user feedback
  • Responsive design — works on mobile and desktop
  • Auto-creation of database and tables on first run
  • Input sanitization and SQL injection prevention

Tech Stack

Layer Technology
Backend PHP 7.4+ (OOP, PDO, MVC-style)
Database MySQL (auto-created via PDO)
Styling Tailwind CSS (CDN)
Interactivity Alpine.js 3.x (CDN)
Server Apache / PHP built-in server

Directory Structure

class/
├── task1.php                          # String & Array Manipulation
├── task2.php                          # Employee Encapsulation
├── task3.php                          # Vehicle Inheritance
├── app/                               # Full CRUD Application
│   ├── config/
│   │   └── Database.php               # Singleton PDO connection
│   ├── models/
│   │   └── Task.php                   # Task model with full CRUD
│   ├── controllers/
│   │   └── TaskController.php         # Request handler & router logic
│   ├── views/
│   │   ├── layout.php                 # Base HTML template
│   │   ├── index.php                  # Task list + stats + search
│   │   ├── create.php                 # Create task form
│   │   ├── edit.php                   # Edit task form
│   │   └── show.php                   # Single task detail view
│   └── public/
│       ├── index.php                  # Front controller (entry point)
│       └── .htaccess                  # Apache URL rewriting
└── README.md                          # This file

Setup Instructions

Prerequisites

  • PHP 7.4 or higher
  • MySQL 5.7 or higher
  • Apache (XAMPP / WAMP / MAMP) — or PHP built-in server

Method 1: XAMPP / WAMP

  1. Start Apache and MySQL from your control panel
  2. Copy the class folder to your web root:
    • XAMPP: C:\xampp\htdocs\class
    • WAMP: C:\wamp64\www\class
  3. Open browser and visit:
    • Assignment files: http://localhost/class/task1.php
    • CRUD app: http://localhost/class/app/public/
  4. The database crud_app and tasks table are created automatically

Method 2: PHP Built-in Server

# Navigate to the project directory
cd c:\Users\GSMOSTAD\Desktop\ostad\class

# Start the server
php -S localhost:8000

# Then visit:
# Assignment: http://localhost:8000/task1.php
# CRUD app:   http://localhost:8000/app/public/

Note: Make sure MySQL is running before starting the server. Database credentials can be changed in app/config/Database.php.


Assignment Tasks

Task 1: String & Array Manipulation (40 marks)

File: task1.php

Processes a list of email strings — trims whitespace, converts names to Title Case, and extracts domain names.

Input:  [" rAHim@gmail.com ", " kArim@outlook.com ", " sUmi@yahoo.com "]
Output: Name: Rahim, Domain: gmail.com
        Name: Karim, Domain: outlook.com
        Name: Sumi, Domain: yahoo.com

Task 2: Employee Management — Encapsulation (30 marks)

File: task2.php

An Employee class with private properties, constructor initialization, and salary management through controlled methods.

$employee = new Employee("Alice", 5000);
$employee->updateSalary(1000);
$employee->getDetails();  // Name: Alice, Salary: 6000

Task 3: Vehicle System — Inheritance (30 marks)

File: task3.php

Demonstrates inheritance with a base Vehicle class and a child Car class using parent::__construct() and method extension.

$myCar = new Car("Toyota", "Corolla");
$myCar->displayDetails();  // This is a Toyota Corolla.

OOP Concepts Used

Concept Where
Encapsulation Task model (private $db, $table), Employee class (private $name, $salary)
Inheritance Car extends Vehicle, layout views extend layout.php pattern
Singleton Pattern Database class — single PDO instance shared across the app
Constructor Used in Database, Task, TaskController, Employee, Vehicle, Car
Prepared Statements All database queries use PDO bindings
Separation of Concerns MVC-style: Model / Controller / Views

Database Schema

The tasks table is created automatically on first connection:

CREATE TABLE tasks (
    id          INT AUTO_INCREMENT PRIMARY KEY,
    title       VARCHAR(255) NOT NULL,
    description TEXT,
    status      ENUM('pending', 'in_progress', 'completed') DEFAULT 'pending',
    priority    ENUM('low', 'medium', 'high') DEFAULT 'medium',
    created_at  TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at  TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

To change database credentials, edit app/config/Database.php:

$host   = '127.0.0.1';
$dbname = 'crud_app';
$user   = 'root';
$pass   = '';

Routing

All requests go through app/public/index.php (front controller):

URL Action Method
/app/public/ List all tasks GET
/app/public/?action=create Show create form GET
/app/public/?action=store Save new task POST
/app/public/?action=show&id=1 View single task GET
/app/public/?action=edit&id=1 Show edit form GET
/app/public/?action=update&id=1 Save updated task POST
/app/public/?action=delete&id=1 Delete a task POST
/app/public/?action=search&q=keyword Search tasks GET

Screenshots

Task List (Index)

Shows all tasks in a responsive table with status/priority badges, stats cards, and a search bar.

Task Detail

Full view of a single task with description, timestamps, and edit/delete actions.

Create / Edit Form

Clean form with title, description, status dropdown, and priority selector.


Author

Built for Ostad — Batch 12, Module 7 Students- Shamim Hossain.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages