RESTful backend for managing a game database, built with modern PHP practices and a DDD-inspired structure.
This project is designed as a study and portfolio application focusing on:
- Layered architecture
- Secure authentication and encryption
- Containerized development
- Scalable environment configuration
- REST API
- JWT Authentication
- Redis caching
- Database migrations with Phinx
- Encryption (Sodium / Defuse)
- Docker-first development
- Unit testing with PHPUnit
- Environment variables with Dotenv
- PHP 8.4
- Nginx
- Composer
- Slim Framework
- PHP-DI
- PHPUnit
- Phinx
- Docker
- Dotenv
- Redis
- MariaDB
The project loosely follows DDD principles:
- Domain
- Application
- Infrastructure
- Presentation
🚧 Active development
TODO List:
- Logger implementation
- API Documentation
GPL-3.0
The project uses layered environment files:
.env
.env.{environment}.{machine}
Example .env to run with Docker under development environment:
.env.development.docker
Copy all keys from .env.example into your environment file and fill in the values.
The docker-compose.development.up and docker-compose.development.down scripts are available to ease the Docker setup.
TIME_ZONE="America/Sao_Paulo"
NGINX_PORT="80"
NGINX_EXPOSE_PORT="8081"
NGINX_PORT: internal container port
NGINX_EXPOSE_PORT: host port mapped to container
API_CONSUMERS_ADDRESSES="http://localhost:8082,http://localhost:8083"
API_CONSUMERS_ADDRESSES_SEPARATOR=","
REPOSITORY_ROOT_USERNAME="backend_root"
REPOSITORY_ROOT_PASSWORD="secret"
REPOSITORY_HOST="database"
REPOSITORY_DATABASE="gamebase"
REPOSITORY_USERNAME="user"
REPOSITORY_PASSWORD="password"
REPOSITORY_PORT="3306"
REPOSITORY_CHARSET="utf8mb4"
REPOSITORY_EXPOSE_PORT="3307"
You may keep the default values, but generating your own keys is recommended.
Access:
http://localhost:{$NGINX_EXPOSE_PORT}/pages/dashboard/home
Then click on:
Defuse EncryptionSodium Encryption
Copy the Key values into:
DEFUSE_PHP_ENCRYPTION_KEY=
SODIUM_CRYPTO_SECRETBOX_KEY=
JWT_SECRET="your-secret-key"
REDIS_SCHEME=redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_EXPOSE_PORT=6380
Access
http://localhost:{$NGINX_EXPOSE_PORT}/pages/dashboard/home
Steps:
- Click on PDO Database → Create
- Verify the database was created
- Click on Phinx
- Ensure the status is OK
All commands are defined in the scripts section of composer.json.
Made with ❤️ by Marcus Vinicius Reis Gonçalves