User Issue Management Backend (PHP) It covers setup, structure, API testing, and dependencies:
# π οΈ User Issue Management System (PHP Backend)
This is a backend system for managing issue calls submitted by users. It supports 3 roles:
- **Public Users**: Can submit new issue calls
- **Manager**: Can view, assign, and close calls
- **Support Engineer**: Can view and resolve assigned calls
JWT-based authentication is used for manager and engineer routes. Built using plain PHP + MySQL (via PDO).sudo apt update
sudo apt install php composer
php -v
composer -V
composer require firebase/php-jwtMake sure you have PHP 8+ and Composer installed. On WSL / Ubuntu:
sudo apt install php composerInside your project directory:
composer require firebase/php-jwt- Create a MySQL database called
issue - Import the schema and demo data:
- Run the db.sql file content on your DB query
-- Run this inside MySQL CLI or phpMyAdmin
SOURCE ./db.sqlOr copy SQL from the setup instructions provided earlier.
Edit your DB credentials and set a strong $jwt_secret (32+ chars):
$host = "localhost";
$user = "root";
$password = "";
$db_name = "issue";
$jwt_secret = "";one-liner
curl -X POST http://localhost/users-issue/api/calls/create.php -H "Content-Type: application/json" -d '{"problem_type": "Login Problem", "user_name": "Jane Doe", "user_email": "[email protected]", "user_phone": "123-456-7890", "description": "Unable to log in since yesterday."}'curl -X POST http://localhost/users-issue/api/auth/manager_login.php -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"managerPass123"}'curl -X POST http://localhost/users-issue/api/auth/engineer_login.php -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"password123"}'Youβll get a token like:
{ "jwt": "eyJhbGciOi..." }Use it in Authorization: Bearer header for protected requests.
- Remember to change the JWT code of the following or any JWT mention here to the freashly generated JWT of your own, this step is vital, else it will throw authentication error.
curl -X GET "http://localhost/users-issue/api/manager/calls_list.php?status=PENDING" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" -H "Content-Type: application/json"curl -X POST http://localhost/users-issue/api/engineer/resolve_call.php -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNjY3MjAsImV4cCI6MTc2ODA3MDMyMCwiZGF0YSI6eyJ1c2VyX2lkIjoiMiIsInJvbGUiOiJTVVBQT1JUX0VOR0lORUVSIn19.RSiLtL3p_WOOGO8vsqiGtjfvjWpc_Lf4fEp4GCx6jzE" -H "Content-Type: application/json" -d '{"call_id": 4, "resolution_status": "RESOLVED", "issue_type": "Router Issue", "remarks": "Replaced router"}'β Get managers profile
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" http://localhost/users-issue/api/manager/profile_get.phpβ edit managers profile
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" -d '{"name":"Jane Manager","email":"[email protected]","phone":"123-456-7890", "status": "ACTIVE"}' http://localhost/users-issue/api/manager/profile_put.phpβ Get pending calls
curl -X GET "http://localhost/users-issue/api/manager/calls_list.php?status=PENDING" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" -H "Content-Type: application/json"β get ongoing calls
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" "http://localhost/users-issue/api/manager/calls_list.php?status=ONGOING"β get closed calls
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" "http://localhost/users-issue/api/manager/calls_list.php?status=CLOSED"β get call details by call id
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" "http://localhost/users-issue/api/manager/call_details.php?id=4"β Assign engineers
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" -d '{"call_id":1,"engineer_id":2}' http://localhost/users-issue/api/manager/assign_engineer.phpβ close call
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" -d '{"call_id":4,"resolution":"Issue fixed","status":"CLOSED", "final_remark": "fixed by engineer id 2"}' http://localhost/users-issue/api/manager/close_call.phpβ get SE list
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" http://localhost/users-issue/api/manager/support_engineers.phpβ report by interval days
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" "http://localhost/users-issue/api/reports/calls_by_interval.php?days=30"β report by performance
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNzM2MzQsImV4cCI6MTc2ODA3NzIzNCwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.sVM60CeNTvQKOtb88b0tZ9CrIqhidnduUxQCWcbqrYc" http://localhost/users-issue/api/reports/engineer_performance.php
β GET: Get SE details
curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgxMTEwMzYsImV4cCI6MTc2ODExNDYzNiwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.VYkzD1qekFR61Ak6RDnAI4wRGCi-laVUGxRp9ZZ751k" -H "Content-Type: application/json" http://localhost/users-issue/api/manager/support_engineer_crud.phpβ POST: Add Engineer
curl -X POST -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgxMTEwMzYsImV4cCI6MTc2ODExNDYzNiwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.VYkzD1qekFR61Ak6RDnAI4wRGCi-laVUGxRp9ZZ751k" -H "Content-Type: application/json" -d '{"name":"Rahul Das","email":"[email protected]","phone":"1234567890","password":"pass123"}' http://localhost/users-issue/api/manager/support_engineer_crud.phpβ PUT: Update Engineer
curl -X PUT -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgxMTEwMzYsImV4cCI6MTc2ODExNDYzNiwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.VYkzD1qekFR61Ak6RDnAI4wRGCi-laVUGxRp9ZZ751k" -H "Content-Type: application/json" -d '{"id":5,"name":"Rahul Das","email":"[email protected]","phone":"0001112222","status":"ACTIVE"}' http://localhost/users-issue/api/manager/support_engineer_crud.phpβ DELETE: Delete Engineer
curl -X DELETE -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgxMTEwMzYsImV4cCI6MTc2ODExNDYzNiwiZGF0YSI6eyJ1c2VyX2lkIjoiMSIsInJvbGUiOiJNQU5BR0VSIn19.VYkzD1qekFR61Ak6RDnAI4wRGCi-laVUGxRp9ZZ751k" -H "Content-Type: application/j" -d "id=5" http://localhost/users-issue/api/manager/support_engineer_crud.phpβ Get engineer profile
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNjY3MjAsImV4cCI6MTc2ODA3MDMyMCwiZGF0YSI6eyJ1c2VyX2lkIjoiMiIsInJvbGUiOiJTVVBQT1JUX0VOR0lORUVSIn19.RSiLtL3p_WOOGO8vsqiGtjfvjWpc_Lf4fEp4GCx6jzE" http://localhost/users-issue/api/engineer/profile_get.phpβ Edit profile
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNjY3MjAsImV4cCI6MTc2ODA3MDMyMCwiZGF0YSI6eyJ1c2VyX2lkIjoiMiIsInJvbGUiOiJTVVBQT1JUX0VOR0lORUVSIn19.RSiLtL3p_WOOGO8vsqiGtjfvjWpc_Lf4fEp4GCx6jzE" -d '{"name":"Eve Engineer","email":"[email protected]","phone":"987-654-3210", "status": "ACTIVE"}' http://localhost/users-issue/api/engineer/profile_put.phpβ Get ongoing calls
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNjY3MjAsImV4cCI6MTc2ODA3MDMyMCwiZGF0YSI6eyJ1c2VyX2lkIjoiMiIsInJvbGUiOiJTVVBQT1JUX0VOR0lORUVSIn19.RSiLtL3p_WOOGO8vsqiGtjfvjWpc_Lf4fEp4GCx6jzE" "http://localhost/users-issue/api/engineer/calls_list.php?status=ONGOING"β get closed calls
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNjY3MjAsImV4cCI6MTc2ODA3MDMyMCwiZGF0YSI6eyJ1c2VyX2lkIjoiMiIsInJvbGUiOiJTVVBQT1JUX0VOR0lORUVSIn19.RSiLtL3p_WOOGO8vsqiGtjfvjWpc_Lf4fEp4GCx6jzE" "http://localhost/users-issue/api/engineer/calls_list.php?status=CLOSED"β Resolve call
curl -X POST http://localhost/users-issue/api/engineer/resolve_call.php -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NjgwNjY3MjAsImV4cCI6MTc2ODA3MDMyMCwiZGF0YSI6eyJ1c2VyX2lkIjoiMiIsInJvbGUiOiJTVVBQT1JUX0VOR0lORUVSIn19.RSiLtL3p_WOOGO8vsqiGtjfvjWpc_Lf4fEp4GCx6jzE" -H "Content-Type: application/json" -d '{"call_id": 4, "resolution_status": "RESOLVED", "issue_type": "Router Issue", "remarks": "Replaced router"}'| Code | Meaning |
|---|---|
| 200 | OK / Success |
| 201 | Created (for new call) |
| 400 | Bad Request |
| 401 | Unauthorized (invalid JWT) |
| 403 | Forbidden (wrong role) |
| 404 | Not Found (call/user) |
| 500 | Internal Server Error |
- Use Postman or
curlfor testing - All input/output is in JSON
- Manager and engineer data is stored in a shared
userstable - Use your own strong secrets for JWT
- Each role has separate login + dashboard logic
- Refresh tokens
- Email notifications to users
- π§ Email: [email protected]
- πΌ LinkedIn
- πΌ Vidwan
- π¬ ORCID
- π GitHub