# holdmyticket/decom_heroku-buildpack-php architecture

> Architecture diagram of the GitHub repository holdmyticket/decom_heroku-buildpack-php, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/holdmyticket/decom_heroku-buildpack-php
- Repository: https://github.com/holdmyticket/decom_heroku-buildpack-php

## Overview

##### Project type and purpose
- This is an open-source buildpack for Heroku targeting PHP applications (with optional Node.js support).
- It orchestrates the app detection, dependency installation (Composer, npm), extension compilation, configuration templating (NGINX, PHP-FPM), and produces a runnable “slug” for Heroku dynos.

##### File structure
- Top-level bins under `bin/`: the core pipeline scripts—detect, compile, release, plus common utility helpers.
- `conf/`: NGINX and PHP templates driving runtime configuration.
- `frameworks/`: per-framework NGINX rules and directory layouts (CakePHP, Symfony, Magento, etc.).
- `support/ext/` and `support/package_*`: source and build manifests for PHP extensions and ancillary packages.
- `requirements.txt`: version pinning for Python scripts (used by some utility routines).
- Root files: `.gitignore`, `README.md`, license, etc.

##### README for additional insights
- The buildpack defines a three-stage pipeline: detect → compile → release.
- Detection hinges on `composer.lock` and/or `index.php`; compile installs Composer and Node dependencies, builds extensions; release scripts output the Procfile/CMD for Heroku.
- Runtimes are NGINX + PHP-FPM (no Apache), with templated configs per framework.

##### Main components
a. Buildpack Pipeline (stages):
- Detect script
- Compile script
– Composer install
– Node/npm install (if `package.json`)
– Extension build harness (uses `support/*`)
– Framework detection & NGINX template selection (`frameworks/*`)
- Release script
– Generates `Procfile`/command to launch NGINX + PHP-FPM
b. Runtime Environment:
- Heroku Router → Dyno
- NGINX (conf from `conf/nginx/*.erb`)
- PHP-FPM workers (php.ini, php-fpm.conf from `conf/php`)
- App code & vendor dependencies (deployed slug)
c. Extensibility & Patterns:
- Plugin-style “framework presets” in `frameworks/`
- Extension packaging under `support/ext` + `support/package_*`
- Template-driven configuration (ERB + environment variables)
- Three-phase pipeline pattern (detect/compile/release)
d. Technologies & Tools:
- Bash scripts (`bin/*`)
- ERB templating for NGINX configs
- Composer (PHP dependency manager)
- Node/NPM (optional asset processing)
- Python utilities (`requirements.txt`) for packaging support
- Heroku slug compiler integration

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source and entry
    SRC["Source Code + Buildpack"]:::artifact
    SRC -->|detect| DETECT
    %% Pipeline stages
    subgraph "Buildpack Pipeline"
        direction TB
        DETECT["Detect Stage"]:::pipeline
        COMPILE["Compile Stage"]:::pipeline
        RELEASE["Release Stage"]:::pipeline

        DETECT -->|passes if composer.lock or index.php| COMPILE
        COMPILE -->|builds slug metadata| RELEASE
        RELEASE -->|"slug created"| SLUG
    end

    %% Compile subcomponents
    subgraph "Compile Stage Details"
        direction TB
        COMPOSER["Composer Install"]:::pipeline
        NODE_INSTALL["npm install (if package.json)"]:::pipeline
        EXT_BUILDER["Extension Build Harness"]:::extensibility
        ANC_PACK["Ancillary Package Manifests"]:::extensibility
        FRAME_DETECT["Framework Detection & NGINX Template Selection"]:::pipeline

        COMPILE --> COMPOSER
        COMPILE --> NODE_INSTALL
        COMPILE --> EXT_BUILDER
        COMPILE --> FRAME_DETECT

        EXT_BUILDER --> ANC_PACK
        FRAME_PRESETS["Framework Presets"]:::extensibility
        FRAME_PRESETS --> FRAME_DETECT
    end

    %% Slug artifact
    SLUG["Deployed Slug"]:::artifact

    %% Runtime environment
    subgraph "Runtime Environment"
        direction TB
        ROUTER["Heroku Router"]:::runtime
        DYNO["Dyno"]:::runtime
        NGINX["NGINX"]:::runtime
        PHPFPM["PHP-FPM"]:::runtime
        APP["App Code & Vendor"]:::artifact

        ROUTER --> DYNO
        SLUG --> DYNO
        DYNO --> NGINX
        NGINX --> PHPFPM
        PHPFPM --> APP
    end

    %% Configuration templates
    TEMPLATE["NGINX Configuration Templates"]:::extensibility
    PHP_CONF["PHP Runtime Configuration"]:::extensibility

    TEMPLATE --> NGINX
    PHP_CONF --> PHPFPM

    %% Utilities
    COMMON["Pipeline Common Utilities"]:::pipeline
    UTIL["Pipeline Utility Scripts"]:::pipeline
    PYREQ["Python Utility Dependencies"]:::extensibility

    DETECT --> COMMON
    COMPILE --> UTIL
    COMPILE --> PYREQ

    %% Click event mappings
    click DETECT "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/bin/detect"
    click COMPILE "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/bin/compile"
    click RELEASE "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/bin/release"
    click COMMON "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/bin/common.sh"
    click UTIL "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/bin/util"
    click TEMPLATE "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/conf/nginx/base.conf.erb"
    click PHP_CONF "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/conf/php/php.ini"
    click PHP_CONF "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/conf/php/php-fpm.conf"
    click PHP_CONF "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/conf/php/newrelic.ini"
    click FRAME_PRESETS "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/frameworks/cakephp2"
    click EXT_BUILDER "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/support/ext/redis"
    click EXT_BUILDER "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/support/ext/imagick"
    click ANC_PACK "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/support/package_nginx"
    click ANC_PACK "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/support/package_php"
    click ANC_PACK "https://github.com/holdmyticket/decom_heroku-buildpack-php/tree/master/support/package_libmcrypt"
    click UTIL "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/bin/util/autotune.php"
    click PYREQ "https://github.com/holdmyticket/decom_heroku-buildpack-php/blob/master/requirements.txt"

    %% Styles
    classDef pipeline fill:#D0E6FF,stroke:#357EDD
    classDef artifact fill:#DFFFE0,stroke:#35DD57
    classDef runtime fill:#FFE0B2,stroke:#DD8535
    classDef extensibility fill:#FFF2B2,stroke:#DDC135
```
