Professional REST API built with Yii2 Framework
Author: Євген М.
- RESTful API with versioning (v1)
- JWT Authentication with token-based security
- Swagger UI documentation at
/swagger/ - CORS configured for cross-origin requests
- MySQL/SQLite support (SQLite for easy demo)
- Database migrations for easy deployment
- Rate limiting for API protection
- PSR-12 code style
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/register |
Register new user |
| POST | /api/v1/auth/login |
Get JWT token |
| GET | /api/v1/auth/me |
Get current user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/projects |
List projects |
| POST | /api/v1/projects |
Create project |
| GET | /api/v1/projects/{id} |
Get project |
| PUT | /api/v1/projects/{id} |
Update project |
| DELETE | /api/v1/projects/{id} |
Delete project |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/tasks |
List tasks |
| POST | /api/v1/tasks |
Create task |
| GET | /api/v1/tasks/{id} |
Get task |
| PUT | /api/v1/tasks/{id} |
Update task |
| DELETE | /api/v1/tasks/{id} |
Delete task |
| PATCH | /api/v1/tasks/{id}/status |
Update status |
- PHP 8.1+ with extensions: curl, mbstring, openssl, pdo_sqlite (or pdo_mysql), intl
- Composer 2.x
# Clone repository
cd d:\main\Project\task-management-api
# Install dependencies
composer install
# Run migrations (creates SQLite database)
php yii migrate --interactive=0
# Start development server
php -S localhost:8080 -t web/- API Documentation: http://localhost:8080/swagger/
- API Root: http://localhost:8080/
# MySQL (default: SQLite)
USE_MYSQL=true
DB_HOST=localhost
DB_PORT=3306
DB_NAME=task_api
DB_USER=root
DB_PASS=your_password
# JWT
JWT_SECRET=your-super-secret-key-256bitCREATE DATABASE task_api CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'taskapi'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON task_api.* TO 'taskapi'@'localhost';curl -X POST http://localhost:8080/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"secret123","name":"John Doe"}'curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"secret123"}'curl -X POST http://localhost:8080/api/v1/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"name":"Website Redesign","description":"Company website project","color":"#e74c3c"}'curl -X POST http://localhost:8080/api/v1/tasks \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"project_id":1,"title":"Setup database","priority":"high","due_date":"2024-12-31"}'# Get overdue tasks
curl "http://localhost:8080/api/v1/tasks?overdue=true" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
# Filter by status and priority
curl "http://localhost:8080/api/v1/tasks?status=in_progress&priority=high" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"task-management-api/
├── components/ # Custom components (JWT, etc.)
├── config/ # Application configuration
│ ├── db.php # Database config
│ ├── web.php # Web app config
│ ├── console.php # Console config
│ └── params.php # Parameters
├── controllers/
│ ├── api/v1/ # API v1 controllers
│ │ ├── AuthController.php
│ │ ├── ProjectController.php
│ │ └── TaskController.php
│ ├── SiteController.php
│ └── SwaggerController.php
├── migrations/ # Database migrations
├── models/ # ActiveRecord models
│ ├── User.php
│ ├── Project.php
│ └── Task.php
├── runtime/ # Logs, cache, SQLite DB
├── setup/ # Installation scripts
├── web/ # Public directory
│ └── index.php # Entry point
├── composer.json
└── README.md
- JWT tokens with configurable expiration
- Password hashing with bcrypt
- Rate limiting (100 requests/minute)
- User isolation (users see only their data)
- Input validation on all endpoints
- SQL injection protection via ActiveRecord
MIT License - Євген М. 2026