A minimal guide to run, test, and use the Collaborative Task Management API.
- REST API for Projects, Tasks, Comments, Notifications
- Layered architecture: Controller → Service → Repository → Model
- Standard JSON errors, pagination, filtering, rate‑limits on sensitive routes
- CI: tests, static analysis (PHPStan), CS (PHP‑CS‑Fixer), dependency review, CodeQL
- Dockerized local setup
- Docker + Docker Compose
- Git
git clone https://github.com/ewmateam/task-api-template.git
cd task-api-template
cp .env.example .env
# Install deps without local PHP
docker run --rm -v %cd%:/app -w /app composer:2 install --ignore-platform-reqs
# Build & run
docker compose build laravel.test
docker compose up -d
# First boot inside container
docker compose exec laravel.test php artisan key:generate
docker compose exec laravel.test php artisan migrateOpen http://localhost.
Import the Postman collection Task API Template.postman_collection.json and environment Task API Template Environment.postman_environment.json into Postman. Select the imported environment, then run the collection to test the API (against http://localhost).
POST /api/register— create userPOST /api/login— login (422 on invalid)
GET /api/users?per_page=&page=— paginated listDELETE /api/users/{id}— delete
GET /api/projects?status=&user_id=&per_page=&page=POST /api/projectsGET /api/projects/{id}PUT /api/projects/{id}DELETE /api/projects/{id}
GET /api/tasks?status=&due_before=&due_after=&search=&per_page=&page=POST /api/tasksGET /api/tasks/{id}PUT /api/tasks/{id}DELETE /api/tasks/{id}
GET /api/tasks/{taskId}/comments?per_page=&page=POST /api/tasks/{taskId}/commentsGET /api/tasks/{taskId}/comments/{commentId}PUT /api/tasks/{taskId}/comments/{commentId}DELETE /api/tasks/{taskId}/comments/{commentId}
GET /api/users/{userId}/notifications?unread_only=&per_page=&page=GET /api/users/{userId}/notifications/unread-countPATCH /api/users/{userId}/notifications/{id}/readPATCH /api/users/{userId}/notifications/mark-all-readDELETE /api/users/{userId}/notifications/{id}
# All tests
docker compose exec laravel.test php artisan test
# Coverage
docker compose exec -e XDEBUG_MODE=coverage laravel.test php artisan test --coverageUseful subsets:
tests/Feature/Auth/*.php
tests/Feature/ProjectsTest.php
tests/Feature/TasksTest.php
tests/Feature/CommentsTest.php
tests/Feature/NotificationsTest.php
- Services encapsulate business logic (e.g., TaskService)
- Repositories abstract data access (e.g., TaskRepositoryInterface → TaskRepository)
- Observer/Event:
TaskUpdated→SendTaskNotification(queued) - Consistent error JSON via custom exception handler
- Caching: task lists (Redis) with simple invalidation
- Run tests on PHP 8.2
- PHPStan + PHP‑CS‑Fixer
- Composer audit + Dependency Review
- CodeQL security analysis
- Dockerized dev workflow
- HTML errors → add
Accept: application/json - DB issues → check
.env, runphp artisan migrate - Config not applied →
php artisan config:clear - Redis port busy → remove host mapping or change port
This project include:
- Unit tests for core services and repositories.
- Integration tests for API endpoints.
- Static analysis (PHPStan/Larastan) to catch potential issues. to achieved 71.6% test coverage.
