# devdrops/php-toolbox architecture

> Architecture diagram of the GitHub repository devdrops/php-toolbox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devdrops/php-toolbox
- Repository: https://github.com/devdrops/php-toolbox

## Overview

##### Main Components Structure

a) Docker Container Layer

b) Configuration Layer
- Configuration components (php.ini, xdebug.ini, opcache.ini, psalm.xml)
- How these configs are mounted into the containers

c) Helper Scripts Layer
- Installation and configuration scripts
- Relationship to the main container build process

##### Component Relationships

- Base Image → Alpine Linux
- Alpine Linux → PHP Installation
- PHP Installation → Extensions & Tools
- Configuration Files → Container Runtime
- Helper Scripts → Build Process

##### Specific Elements

- Base Docker Image (Alpine)
- PHP Runtime (different versions)
- Development Tools (PHPUnit, PHPCS, PHPStan, etc.)
- Configuration Management
- Build System (Makefile)
- CI/CD Integration (.github/workflows)

##### Flow Directions

Primary flows:
- Build Process Flow: Dockerfile → Helper Scripts → Final Image
- Runtime Flow: Source Code Mount → Container → Development Tools
- Configuration Flow: Config Files → Container Runtime

##### Specific Implementation Details

Technical elements:
- Volume mounting points (/code)
- Tool execution paths
- Configuration injection points
- CI/CD pipeline integration

##### The build and deployment workflow

Keep the abstraction level focused on the container architecture while showing how the development tools are integrated into the system. This will help developers understand both the build process and how to use the toolbox effectively.

Remember to include GitHub Actions integration points and Docker Hub publication flow, as these are crucial parts of the project's infrastructure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Base Layer"
        Alpine["Alpine Linux Base Image"]:::base
    end

    subgraph "PHP Runtime Layer"
        PHP74["PHP 7.4 Container"]:::php
        PHP80["PHP 8.0 Container"]:::php
        PHP81["PHP 8.1 Container"]:::php
        PHP82["PHP 8.2 Container"]:::php
        PHP83["PHP 8.3 Container"]:::php
    end

    subgraph "Configuration Layer"
        PHPConfig["PHP Configuration"]:::config
        XDebugConfig["XDebug Configuration"]:::config
        OPCacheConfig["OPCache Configuration"]:::config
        PsalmConfig["Psalm Configuration"]:::config
    end

    subgraph "Helper Scripts Layer"
        AlpineDeps["Alpine Dependencies"]:::helper
        ComposerInstall["Composer Installation"]:::helper
        PHPExt["PHP Extensions"]:::helper
        RedisInstall["Redis Installation"]:::helper
        SwooleInstall["Swoole Installation"]:::helper
        XDebugInstall["XDebug Installation"]:::helper
    end

    subgraph "Development Tools"
        Tools["Development Tools Installation"]:::tools
        ComposerConfig["Composer Configuration"]:::tools
    end

    subgraph "CI/CD Layer"
        DockerPublish["Docker Publishing"]:::cicd
        SecurityScan["Security Scanning"]:::cicd
    end

    subgraph "Build System"
        Makefile["Build Configuration"]:::build
    end

    Alpine --> PHP74 & PHP80 & PHP81 & PHP82 & PHP83
    PHPConfig & XDebugConfig & OPCacheConfig & PsalmConfig --> PHP83
    AlpineDeps & ComposerInstall & PHPExt & RedisInstall & SwooleInstall & XDebugInstall --> PHP83
    Tools & ComposerConfig --> PHP83
    Makefile --> DockerPublish
    PHP83 --> DockerPublish
    DockerPublish --> SecurityScan

    %% Click Events
    click PHP74 "https://github.com/devdrops/php-toolbox/tree/main/7.4/Dockerfile"
    click PHP80 "https://github.com/devdrops/php-toolbox/tree/main/8.0/Dockerfile"
    click PHP81 "https://github.com/devdrops/php-toolbox/tree/main/8.1/Dockerfile"
    click PHP82 "https://github.com/devdrops/php-toolbox/tree/main/8.2/Dockerfile"
    click PHP83 "https://github.com/devdrops/php-toolbox/tree/main/8.3/Dockerfile"
    click PHPConfig "https://github.com/devdrops/php-toolbox/blob/main/8.3/config-files/php/php.ini"
    click XDebugConfig "https://github.com/devdrops/php-toolbox/blob/main/8.3/config-files/xdebug/xdebug.ini"
    click OPCacheConfig "https://github.com/devdrops/php-toolbox/blob/main/8.3/config-files/opcache/opcache.ini"
    click PsalmConfig "https://github.com/devdrops/php-toolbox/blob/main/8.3/config-files/psalm/psalm.xml"
    click AlpineDeps "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/alpine/dependencies.sh"
    click ComposerInstall "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/composer/install.sh"
    click PHPExt "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/php/extensions.sh"
    click RedisInstall "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/redis/install.sh"
    click SwooleInstall "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/swoole/install.sh"
    click XDebugInstall "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/xdebug/install.sh"
    click Makefile "https://github.com/devdrops/php-toolbox/tree/main/8.3/Makefile"
    click DockerPublish "https://github.com/devdrops/php-toolbox/blob/main/.github/workflows/publish-docker-image.yml"
    click Tools "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/composer/install-tools.sh"
    click ComposerConfig "https://github.com/devdrops/php-toolbox/blob/main/8.3/helpers/composer/config.sh"

    %% Styling
    classDef base fill:#f9f,stroke:#333
    classDef php fill:#69f,stroke:#333
    classDef config fill:#ff9,stroke:#333
    classDef helper fill:#9cf,stroke:#333
    classDef tools fill:#9f9,stroke:#333
    classDef cicd fill:#f99,stroke:#333
    classDef build fill:#999,stroke:#333
```
