A RESTful API for managing tasks built with Symfony and API Platform.
- Docker & Docker Compose
- PHP 8.2+ (if running locally without Docker)
- Composer
cd task-manager-api
composer installCreate a .env.local file (or use the existing .env):
DATABASE_URL="mysql://task_manager_user:task_manager_password@mysql:3306/task_manager_api"
docker-compose up -dThis will start:
- PHP App: http://localhost:8000
- MySQL Database: localhost:3311
docker-compose exec app php bin/console doctrine:migrations:migrateOr if running locally:
php bin/console doctrine:migrations:migrateVisit the endpoints:
- API Documentation: http://localhost:8000/api
- Get All Tasks: http://localhost:8000/api/tasks
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/tasks |
Get all tasks |
| GET | /api/tasks/{id} |
Get a specific task |
| POST | /api/tasks |
Create a new task |
| PUT | /api/tasks/{id} |
Update a task (all fields) |
| PATCH | /api/tasks/{id} |
Partially update a task |
| DELETE | /api/tasks/{id} |
Delete a task |
Create a Task (POST)
curl -X POST http://localhost:8000/api/tasks \
-H "Content-Type: application/json" \
-d '{"title": "Buy groceries", "description": "Milk, eggs, bread"}'Get All Tasks (GET)
curl http://localhost:8000/api/tasksMark Task as Completed (PATCH)
curl -X PATCH http://localhost:8000/api/tasks/1 \
-H "Content-Type: application/json" \
-d '{"isCompleted": true}'Update Task (PUT)
curl -X PUT http://localhost:8000/api/tasks/1 \
-H "Content-Type: application/json" \
-d '{"title": "Buy groceries", "description": "Updated list", "isCompleted": false}'Delete Task (DELETE)
curl -X DELETE http://localhost:8000/api/tasks/1Tasks have the following properties:
id(integer): Unique identifiertitle(string): Task titledescription(string, nullable): Task descriptionisCompleted(boolean): Completion status (default: false)createdAt(datetime): Creation timestamp (auto-set)
Database Name: task_manager_api
Task Table:
CREATE TABLE task (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description LONGTEXT,
is_completed TINYINT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL
)- Framework: Symfony 6.x
- API Platform: API-Platform 3.x
- ORM: Doctrine ORM
- Database: MySQL 8.0
- Container: Docker
docker-compose downdocker-compose logs -f appdocker-compose exec mysql mysql -u task_manager_user -p task_manager_api- API Platform automatically exposes the Task entity as REST resources
- Default API documentation is available at
/api - All responses are JSON serialized with appropriate HTTP status codes
- Date times are stored as immutable in the database