RESTful backend for managing a game database, built with modern PHP practices and a DDD-inspired structure.
- REST API
- JWT Authentication
- Redis caching
- Database migrations with Phinx
- Encryption (Sodium / Defuse)
- Docker-first development
- Unit testing with PHPUnit
- Environment variables with Dotenv
- Logging system with Monolog
- OpenAPI Documentation
- Internal Dashboard
- PHP 8.4
- Nginx
- Composer
- Slim Framework
- PHP-DI
- PHPUnit
- Monolog
- Phinx
- Docker
- OpenAPI
- Dotenv
- Redis
- MariaDB
- Twig
🚧 Active development
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.
Inform it on IANA Format, for example:
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=","
The addresses will be tokenized based on the separator character.
REPOSITORY_ROOT_USERNAME="username"
REPOSITORY_ROOT_PASSWORD="password"
REPOSITORY_HOST="database"
REPOSITORY_DATABASE="gamebase"
REPOSITORY_USERNAME="username"
REPOSITORY_PASSWORD="password"
REPOSITORY_PORT="3306"
REPOSITORY_CHARSET="utf8mb4"
REPOSITORY_EXPOSE_PORT="3307"
REPOSITORY_PORT: internal container port
REPOSITORY_EXPOSE_PORT: host port mapped to container
For Docker, ensure REPOSITORY_HOST has the same value as the name of the database container. Ex: REPOSITORY_HOST="mariadb"
You may keep the default values, but generating your own keys is recommended.
Access:
http://localhost:{$NGINX_EXPOSE_PORT}/pages/login
Then click on:
Defuse EncryptionSodium EncryptionJwt Encryption
Copy the Key values into:
DEFUSE_PHP_ENCRYPTION_KEY=
SODIUM_CRYPTO_SECRETBOX_KEY=
JWT_SECRET=
REDIS_SCHEME=redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_EXPOSE_PORT=6380
REDIS_PORT: internal container port
REDIS_EXPOSE_PORT: host port mapped to container
For Docker, ensure REDIS_HOST has the same value as the name of the redis container. Ex: REDIS_HOST="redis"
Access
http://localhost:{$NGINX_EXPOSE_PORT}/pages/login
To make first login, use REPOSITORY_ROOT_USERNAME and REPOSITORY_ROOT_PASSWORD provided on the .env.enviroment.machine.example file.
After that, do the following steps:
- Click on PDO Database
- Verify if the database was created. If not, click on Create.
- Click on Phinx
- Ensure the status is OK. It will only work if the database exists.
Run the following command to generate the OpenAPI documentation:
/configurations/openapi/startup/startup.sh
On the root folder of the project.
Run the scripts to control the Docker containers:
/configurations/docker/scripts/development/build.sh
/configurations/docker/scripts/development/kill.sh
/configurations/docker/scripts/development/logs.sh
On the root folder of the project.
The logs folder is located in:
/logs/
On the root folder of the project.
All commands are defined in the scripts section of composer.json.
Made with ❤️ by Marcus Vinicius Reis Gonçalves