responsive-sk/hdm-boot

HDM Boot - Hexagonal + DDD + Modular Monolith Architecture Framework

v0.9.0 2025-06-22 18:27 UTC

This package is not auto-updated.

Last update: 2025-07-07 17:55:45 UTC


README

Enterprise PHP framework with Triple Architecture: Hexagonal + DDD + Modular Monolith

PHP Version Framework Architecture License Tests

๐Ÿš€ Features

๐Ÿ›๏ธ Triple Architecture

  • Hexagonal Architecture - Clean separation of business logic from infrastructure
  • Domain-Driven Design - Rich domain models with clear boundaries
  • Modular Monolith - Independent modules with clear interfaces

๐Ÿ” Security First

  • JWT Authentication - Secure token-based authentication
  • CSRF Protection - Cross-site request forgery prevention
  • Secure Sessions - Enterprise-grade session management
  • Path Safety - Safe file system operations with responsive-sk/slim4-paths
  • Directory Protection - .htaccess protection for sensitive directories
  • Path Traversal Prevention - Secure path resolution with Paths service

๐ŸŒ Internationalization

  • Multi-language Support - Slovak, Czech, English, and more
  • Automatic Detection - Browser and user preference detection
  • Gettext Integration - Professional translation workflow
  • Locale Management - Dynamic language switching

๐Ÿ—๏ธ Full Module Isolation

  • Independent Modules - Each module can have its own composer.json
  • Module-specific Testing - Isolated test suites with PHPUnit
  • CI/CD per Module - GitHub Actions for individual modules
  • Marketplace Ready - Open-source plugin ecosystem support

๐Ÿ“Š Enterprise Ready

  • Comprehensive Logging - Monolog with multiple handlers
  • Health Monitoring - Multiple health check endpoints
  • Database Abstraction - Multiple storage engines support
  • Production Deployment - Complete deployment guides and validation

๐Ÿ“ฆ Installation

Quick Start

composer create-project responsive-sk/hdm-boot my-project
cd my-project
cp .env.example .env
# Configure your .env file
composer install

Development Setup

# Clone repository
git clone https://github.com/responsive-sk/hdm-boot.git
cd hdm-boot

# Install dependencies
composer install

# Configure environment
cp .env.example .env
php bin/generate-keys.php

# Validate environment
php bin/validate-env.php

# Fix permissions
php bin/fix-permissions.php

# Start development server
php -S localhost:8000 -t public/

Production Deployment

# Build production package
php bin/build-production.php

# Upload generated ZIP to your server via FTP/FTPS
# Extract files and configure .env
# Visit your website to complete setup

๐Ÿ“‹ Complete deployment guide: docs/DEPLOYMENT_GUIDE.md

๐Ÿ“ Directory Structure

HDM Boot follows an organized directory structure with runtime data consolidated under var/:

project/
โ”œโ”€โ”€ var/                    # Runtime data (protected)
โ”‚   โ”œโ”€โ”€ storage/           # Database files
โ”‚   โ”‚   โ”œโ”€โ”€ mark.db       # Mark system database
โ”‚   โ”‚   โ”œโ”€โ”€ user.db       # User system database
โ”‚   โ”‚   โ””โ”€โ”€ system.db     # Core system database
โ”‚   โ”œโ”€โ”€ logs/              # Application logs
โ”‚   โ”œโ”€โ”€ cache/             # Cache files
โ”‚   โ””โ”€โ”€ sessions/          # Session data
โ”œโ”€โ”€ content/               # Content files (Git-friendly)
โ”‚   โ”œโ”€โ”€ articles/          # Markdown articles
โ”‚   โ””โ”€โ”€ docs/              # Documentation
โ”œโ”€โ”€ templates/             # Template files
โ”‚   โ”œโ”€โ”€ layouts/
โ”‚   โ””โ”€โ”€ partials/
โ”œโ”€โ”€ public/                # Web-accessible files only
โ”‚   โ”œโ”€โ”€ assets/
โ”‚   โ””โ”€โ”€ media/
โ”œโ”€โ”€ src/                   # Application source code
โ”‚   โ”œโ”€โ”€ Modules/
โ”‚   โ””โ”€โ”€ SharedKernel/
โ””โ”€โ”€ config/
    โ””โ”€โ”€ paths.php          # Path configuration

Key Benefits:

  • Security - Sensitive files outside web root
  • Organization - Clear separation of concerns
  • Protection - .htaccess files protect sensitive directories
  • Flexibility - Configurable paths via config/paths.php

๐Ÿ“‹ Paths Service Guide: docs/PATHS_SERVICE_GUIDE.md

๐Ÿ—๏ธ Architecture

HDM Boot implements Triple Architecture combining three enterprise patterns:

1. Hexagonal Architecture (Ports & Adapters)

Application Core
โ”œโ”€โ”€ Domain/          # Business logic
โ”œโ”€โ”€ Application/     # Use cases
โ””โ”€โ”€ Ports/          # Interfaces

Infrastructure
โ”œโ”€โ”€ Adapters/       # External integrations
โ”œโ”€โ”€ Persistence/    # Database implementations
โ””โ”€โ”€ Web/           # HTTP controllers

2. Domain-Driven Design (DDD)

Domain/
โ”œโ”€โ”€ Entities/       # Business objects
โ”œโ”€โ”€ ValueObjects/   # Immutable values
โ”œโ”€โ”€ Repositories/   # Data access interfaces
โ”œโ”€โ”€ Services/       # Domain services
โ””โ”€โ”€ Events/        # Domain events

3. Modular Monolith

src/Modules/
โ”œโ”€โ”€ Core/           # Essential modules
โ”‚   โ”œโ”€โ”€ User/       # User management
โ”‚   โ”œโ”€โ”€ Security/   # Authentication & authorization
โ”‚   โ”œโ”€โ”€ Template/   # View rendering
โ”‚   โ””โ”€โ”€ Session/    # Session management
โ””โ”€โ”€ Optional/       # Feature modules
    โ”œโ”€โ”€ Blog/       # Blog functionality (Full Module Isolation)
    โ””โ”€โ”€ Ecommerce/  # E-commerce features

๐Ÿ”ง Configuration

Environment Variables

# Application
APP_NAME="HDM Boot"
APP_ENV=prod
APP_DEBUG=false
APP_TIMEZONE=UTC

# Database
DATABASE_URL="sqlite:var/storage/app.db"

# Security
JWT_SECRET="your-64-character-secret-key"
JWT_EXPIRY=3600

# Modules
ENABLED_MODULES="Blog"

# Sessions
SESSION_NAME="hdm_boot_session"
SESSION_LIFETIME=7200
SESSION_COOKIE_SECURE=true
SESSION_COOKIE_HTTPONLY=true

# Localization
DEFAULT_LOCALE=en_US
DEFAULT_TIMEZONE=Europe/Bratislava
ENABLE_SLOVAK=true
ENABLE_CZECH=true

Module Configuration

Enable/disable modules in .env:

ENABLED_MODULES="Blog,Ecommerce,Analytics"

๐Ÿงช Testing

Framework Tests

# Run all tests
composer test

# Run specific test suites
composer test:unit
composer test:integration
composer test:functional

# Generate coverage report
composer test:coverage

# Code quality checks
composer cs:check
composer analyse

Module-specific Tests (Full Module Isolation)

# Blog module tests
cd src/Modules/Optional/Blog
composer test
composer test:coverage

# Run via module test runner
php run-module-tests.php
php run-module-tests.php --coverage

Test Statistics

  • Framework Tests: 39 tests, 98 assertions
  • Blog Module Tests: 39 tests, 98 assertions
  • Total Coverage: 90%+ target
  • Code Quality: PHPStan Level 8

๐Ÿ—๏ธ Full Module Isolation

HDM Boot supports Full Module Isolation for enterprise development:

Blog Module Example

src/Modules/Optional/Blog/
โ”œโ”€โ”€ composer.json              # Independent package
โ”œโ”€โ”€ vendor/                    # Module dependencies (84KB optimized)
โ”œโ”€โ”€ phpunit.xml               # Module-specific testing
โ”œโ”€โ”€ run-module-tests.php      # Paths-powered test runner
โ”œโ”€โ”€ tests/                    # 39 tests, 98 assertions
โ”œโ”€โ”€ README.md                 # Module documentation
โ”œโ”€โ”€ .github/workflows/ci.yml  # Module CI/CD
โ””โ”€โ”€ src/                      # Module source code

Module Development

# Create new isolated module
mkdir -p src/Modules/Optional/MyModule
cd src/Modules/Optional/MyModule

# Initialize module
composer init
composer require responsive-sk/slim4-paths

# Add testing
composer require --dev phpunit/phpunit
cp ../Blog/phpunit.xml .
cp ../Blog/run-module-tests.php .

# Run module tests
composer test

Benefits

  • โœ… Independent Development - Teams can work on modules separately
  • โœ… Separate CI/CD - Module-specific GitHub Actions
  • โœ… Version Management - Independent module versioning
  • โœ… Marketplace Ready - Modules can be published as packages
  • โœ… Path Safety - Uses responsive-sk/slim4-paths for secure operations

๐Ÿ› ๏ธ Development Tools

Code Quality

# Route discovery
php bin/route-list.php

# Environment validation
php bin/validate-env.php

# Key generation
php bin/generate-keys.php

# Module isolation check
php -r "
\$moduleManager = \$container->get('ModuleManager');
\$info = \$moduleManager->getModuleIsolationInfo('Blog');
var_dump(\$info);
"

Debugging

# Enable debug mode
echo "APP_DEBUG=true" >> .env

# View logs
tail -f var/logs/app.log

# Check module status
php bin/route-list.php | grep -i blog

๐Ÿ“š Documentation

๐Ÿš€ Production Deployment

Quick Deployment

# 1. Generate secure keys
php bin/generate-keys.php

# 2. Configure production environment
cp .env.example .env
# Edit .env with production values

# 3. Validate environment
php bin/validate-env.php

# 4. Deploy
composer install --no-dev --optimize-autoloader
composer deploy:prod

# 5. Verify deployment
curl https://yourdomain.com/health

Production Checklist

  • โœ… Environment: APP_ENV=prod, APP_DEBUG=false
  • โœ… Security: Strong JWT_SECRET (64+ characters)
  • โœ… Database: Production database configured
  • โœ… Sessions: Secure session configuration
  • โœ… HTTPS: SSL/TLS enabled
  • โœ… Monitoring: Health endpoints configured
  • โœ… Logging: Production log levels set

๐ŸŒŸ Live Demo

Production Instance: https://boot.responsive.sk/

๐Ÿค Contributing

Framework Contributions

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Run tests: composer test
  4. Commit changes: git commit -m 'Add amazing feature'
  5. Push to branch: git push origin feature/amazing-feature
  6. Open Pull Request

Module Contributions

  1. Create isolated module in src/Modules/Optional/
  2. Add module-specific tests and CI
  3. Document module in README.md
  4. Submit as separate package or PR

Development Guidelines

  • โœ… PSR-12 code style
  • โœ… PHPStan Level 8 static analysis
  • โœ… 90%+ test coverage requirement
  • โœ… Semantic versioning for releases
  • โœ… Conventional commits for changelog

๐Ÿ“Š Project Statistics

  • Framework Version: 0.9.0 (Release Candidate)
  • PHP Requirement: 8.2+
  • Dependencies: 20+ packages
  • Test Coverage: 90%+
  • Code Quality: PHPStan Level 8
  • Modules: 8 Core + 1 Optional (Blog)
  • Routes: 29 endpoints
  • Documentation: 6 guides

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ”— Links

๐Ÿ† Acknowledgments

  • Slim Framework - Micro framework foundation
  • PHP-DI - Dependency injection container
  • Monolog - Logging library
  • PHPUnit - Testing framework
  • responsive.sk - Development team

HDM Boot Framework - Enterprise PHP development with Triple Architecture

Built with โค๏ธ by the HDM Boot Team