Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo API

REST API built with Slim 4, Eloquent ORM, Redis and JWT authentication.

Stack

Layer Technology
Framework Slim 4
ORM Illuminate Eloquent 11
Cache Illuminate Cache + Redis
Auth Custom JWT (HS256)
Container Illuminate Container
CLI Symfony Console
Web server Nginx + PHP 8.4-FPM
Database MySQL 8

Quick Start

make init

This will:

  1. Copy .env.example.env
  2. Build Docker images
  3. Start all containers
  4. Wait for MySQL to be ready
  5. Run migrations
Service URL
API http://localhost:8080
Swagger UI http://localhost:8082

Make Commands

make up               # start containers
make down             # stop containers
make logs             # stream logs

make migrate          # run pending migrations
make rollback         # rollback last batch
make migration name=create_tags_table  # create new migration

make shell            # bash into app container
make shell-mysql      # MySQL CLI
make shell-redis      # Redis CLI

API Overview

POST   /api/v1/auth/register
POST   /api/v1/auth/login
POST   /api/v1/auth/refresh
POST   /api/v1/auth/logout         [auth]

GET    /api/v1/posts
GET    /api/v1/posts/my            [auth]
GET    /api/v1/posts/{id}
POST   /api/v1/posts               [auth]
PUT    /api/v1/posts/{id}          [auth]
DELETE /api/v1/posts/{id}          [auth]

GET    /api/v1/posts/{id}/comments
GET    /api/v1/comments/my         [auth]
POST   /api/v1/posts/{id}/comments [auth]
PUT    /api/v1/comments/{id}       [auth]
DELETE /api/v1/comments/{id}       [auth]

Full spec available in openapi.yaml and at Swagger UI.

Project Structure

src/
├── Contracts/        # Interfaces (IMigrationTool)
├── Dto/              # Data Transfer Objects
├── Handlers/
│   ├── API/          # HTTP handlers (Auth, Post, Comment)
│   ├── Console/      # CLI commands (migrate, rollback, make:migration)
│   ├── Middleware/   # AuthMiddleware
│   └── Response/     # ApiResponse
├── Migrations/       # Database migrations
├── Models/           # Eloquent models (User, Post, Comment)
├── Repository/       # Data access layer
└── Services/         # Business logic (Auth, JWT, User, Post, Comment, Credential)
config/               # database, cache, container
routes/               # api.php, console.php
docker/               # Dockerfile, nginx config

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages