Beauty Framework app

1.0.0 2025-06-10 23:46 UTC

This package is not auto-updated.

Last update: 2025-06-11 21:57:55 UTC


README

logo

๐Ÿงฑ Beauty Framework

Beauty is a blazing-fast, PSR-compliant, modular microframework for building REST and gRPC APIs on top of RoadRunner. It provides first-class support for clean architecture, strong developer ergonomics, and production-ready features without FPM overhead.

๐ŸŽฏ Goals

Beauty is designed as a lightweight, modular and fast foundation for building microservices:

  • ๐Ÿงฉ Package-oriented: each module is self-contained and reusable
  • ๐Ÿš€ RoadRunner-native: zero FPM, ultra-low latency
  • โš™๏ธ Clean architecture: clear separation between application layers
  • ๐Ÿงช Testing-friendly: services are testable by design
  • ๐Ÿณ Docker-first: fully containerized by default

๐Ÿš€ Features

  • Fully PSR-compliant (PSR-3, 4, 7, 11, 15, 14)
  • Built-in DI container (PHP-DI powered)
  • Attribute-based routing and middleware
  • Event system with listener registry
  • Lightweight config and cache system
  • Jobs, events, queues (via RoadRunner)
  • Console kernel for CLI tools
  • Powered by RoadRunner โ€” no FPM

๐Ÿ—‚ Project Structure

โ”œโ”€โ”€ app
โ”‚   โ”œโ”€โ”€ Console         # CLI commands
โ”‚   โ”œโ”€โ”€ Container       # DI bindings for core services
โ”‚   โ”œโ”€โ”€ Controllers     # HTTP/API controllers
โ”‚   โ”œโ”€โ”€ Events          # Application events
โ”‚   โ”œโ”€โ”€ Jobs            # Async jobs
โ”‚   โ”œโ”€โ”€ Listeners       # Event listeners
โ”‚   โ”œโ”€โ”€ Middlewares     # PSR-15 middleware
โ”‚   โ”œโ”€โ”€ Requests        # Validated requests
โ”‚   โ”œโ”€โ”€ Responses       # Typed responses
โ”‚   โ”œโ”€โ”€ Repositories    # Data access
โ”‚   โ””โ”€โ”€ Services        # Business logic
โ”œโ”€โ”€ config              # Configuration files
โ”œโ”€โ”€ workers             # RoadRunner workers (http, jobs, etc)
โ”œโ”€โ”€ bootstrap           # Kernel bootstrapping
โ”œโ”€โ”€ public/index.php    # Entry point (optional)

๐Ÿ“ฆ Installation

composer create-project beauty-framework/app beauty-framework
cd beauty-framework
cp .env.example .env
make up # or make prod

โš™๏ธ Configuration (.env)

APP_NAME=Beauty
APP_ENV=local
APP_VERSION=1.0
APP_TIMEZONE=UTC
APP_LOCALE=en
APP_DEBUG=true
USE_DI_CACHE=true

DB_CONNECTION=pgsql
DB_HOST=database
DB_PORT=5432
DB_DATABASE=my_db
DB_USERNAME=root
DB_PASSWORD=password

CACHE_DRIVER=redis

REDIS_HOST=redis
REDIS_PORT=6379

๐Ÿง  CLI Commands

Command Description
generate:controller Generate controller
generate:command Generate a new CLI command
generate:middleware Generate a new middleware
generate:request Generate a new request
generate:event Create a new event
generate:listener Create a new listener
generate:job Create a new job

๐Ÿณ Docker Setup (default)

Beauty is designed to run natively inside Docker. By default, all services are containerized:

Service Image Notes
app php:8.4-alpine + RR RoadRunner + CLI build targets
db postgres:16 PostgreSQL 16
redis redis:alpine Redis 7
services:
  app:
    build:
      target: dev
    environment:
      PHP_IDE_CONFIG: "serverName=stage"
    restart: unless-stopped

  db:
    image: postgres:16
    ports:
      - "5432:5432"

  redis:
    image: redis:alpine
    ports:
      - "6379:6379"

๐Ÿ›  Makefile Commands

Category Command Description
Start make up Start the DEV environment
make prod Start the PROD environment
Stop make stop Stop all containers
make down Remove all containers and volumes
make restart Restart all containers
make restart-container CONTAINER=... Restart a specific container
make stop-container CONTAINER=... Stop a specific container
PHP make php <cmd> Run php command inside the app container
make beauty <cmd> Run beauty CLI command inside the app container
Tests make test Run PHPUnit tests
Composer make composer <cmd> Run composer command inside the app container
Shell make bash Open bash shell inside the app container
Logs make logs <container> View logs of specific container
Database make psql Access PostgreSQL CLI
Cache make redis Access Redis CLI

๐Ÿ“š Documentation

Work in progress: see docs/README.md

๐Ÿ“ฆ Related Modules

๐Ÿ“ TODO

  • ORM support (query builder + migrations)
  • beauty/testing package with framework-aware test harness
  • gRPC server module with RoadRunner integration
  • Job retries, delays, and failure handlers
  • OpenAPI/Swagger support
  • Full module documentation

Welcome to Beauty Framework โ€” lean, fast, clean. Let's build some serious APIs โšก