Simple REST API built with PHP and MySQL for task management.
- ✅ Create tasks
 - ✅ Read all tasks
 - ✅ Update tasks
 - ✅ Delete tasks
 - ✅ JSON responses
 - ✅ CORS enabled
 - ✅ PDO with prepared statements (SQL injection protection)
 
- PHP 7.4+
 - MySQL 5.7+
 - REST architecture
 
- Clone repository
 
git clone https://github.com/YOUR_USERNAME/todo-api.git
cd todo-api- Setup database
 
mysql -u root -p < database.sql- Configure database connection
 
Edit config/database.php with your credentials:
private $host = "localhost";
private $db_name = "todo_api";
private $username = "your_username";
private $password = "your_password";- Start local server
 
php -S localhost:8000Get all tasks
Response:
{
  "records": [
    {
      "id": 1,
      "title": "Task title",
      "description": "Task description",
      "completed": false,
      "created_at": "2024-10-29 23:00:00",
      "updated_at": "2024-10-29 23:00:00"
    }
  ]
}Create new task
Request:
{
  "title": "New task",
  "description": "Task description",
  "completed": false
}Update existing task
Request:
{
  "id": 1,
  "title": "Updated task",
  "description": "Updated description",
  "completed": true
}Delete task
Request:
{
  "id": 1
}Get all tasks:
curl http://localhost:8000/api/read.phpCreate task:
curl -X POST http://localhost:8000/api/create.php \
  -H "Content-Type: application/json" \
  -d '{"title":"Test task","description":"Testing API","completed":false}'Update task:
curl -X PUT http://localhost:8000/api/update.php \
  -H "Content-Type: application/json" \
  -d '{"id":1,"title":"Updated task","completed":true}'Delete task:
curl -X DELETE http://localhost:8000/api/delete.php \
  -H "Content-Type: application/json" \
  -d '{"id":1}'- Prepared statements (SQL injection protection)
 - Input sanitization with 
htmlspecialchars() - CORS headers configured
 - Error handling
 
MIT
Denys Chorny Savchuk