# agussuroyo/container architecture

> Architecture diagram of the GitHub repository agussuroyo/container, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agussuroyo/container
- Repository: https://github.com/agussuroyo/container

## Overview

This is a small PHP dependency-injection library. An application calls `get()` to receive a cached instance, a bound factory result, or an auto-wired object. Auto-wiring reflects on the class constructor and recursively asks the container to resolve class-typed parameters, using defaults where available. `make()` bypasses the instance cache; binding, binding checks, and cache clearing are separate container operations. Runtime behavior is concentrated in `src/Container.php`; the README documents these capabilities, but no separate implementation modules are present.

Main entry points: [`src/Container.php`](https://github.com/agussuroyo/container/blob/master/src/Container.php) (Get instance)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_application(("Application"))
node_container["Container<br/>[Container.php]"]
node_get["Get instance<br/>[Container.php]"]
node_bindings["Bind mapping<br/>[Container.php]"]
node_cache["Instance cache<br/>[Container.php]"]
node_make["Make instance<br/>[Container.php]"]
node_reflection["PHP reflection"]
node_dependencies["Resolve dependencies<br/>[Container.php]"]
node_factory["Bound factory"]
node_bound["Check binding<br/>[Container.php]"]
node_clear["Clear cache<br/>[Container.php]"]

node_application -->|"requests instance"| node_get
node_application -->|"requests fresh"| node_make
node_application -->|"registers binding"| node_bindings
node_application -->|"checks binding"| node_bound
node_application -->|"clears cache"| node_clear
node_get -->|"checks and stores"| node_cache
node_get -->|"looks up binding"| node_bindings
node_get -->|"invokes bound factory"| node_factory
node_get -->|"auto-resolves"| node_make
node_get -->|"returns instance"| node_application
node_bindings -->|"stores mapping"| node_container
node_make -->|"inspects class"| node_reflection
node_make -->|"resolves constructor args"| node_dependencies
node_reflection -->|"provides class metadata"| node_make
node_dependencies -->|"resolves class parameters"| node_get
node_clear -->|"removes instances"| node_cache
node_bound -->|"checks mapping"| node_bindings
node_bound -->|"checks instance"| node_cache

click node_container "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_get "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_bindings "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_cache "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_make "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_dependencies "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_bound "https://github.com/agussuroyo/container/blob/master/src/Container.php"
click node_clear "https://github.com/agussuroyo/container/blob/master/src/Container.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_reflection,node_factory toneIndigo
class node_container,node_get,node_bindings,node_make,node_dependencies,node_bound toneTeal
class node_cache,node_clear toneAmber
```

## Components

### Other components

- **Application**
- [Container](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- [Get instance](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- [Bind mapping](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- [Instance cache](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- [Make instance](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- **PHP reflection**
- [Resolve dependencies](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- **Bound factory**
- [Check binding](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`
- [Clear cache](https://github.com/agussuroyo/container/blob/master/src/Container.php): `src/Container.php`

## Connections

- Application → Get instance: requests instance
- Application → Make instance: requests fresh
- Application → Bind mapping: registers binding
- Application → Check binding: checks binding
- Application → Clear cache: clears cache
- Get instance → Instance cache: checks and stores
- Get instance → Bind mapping: looks up binding
- Get instance → Bound factory: invokes bound factory
- Get instance → Make instance: auto-resolves
- Get instance → Application: returns instance
- Bind mapping → Container: stores mapping
- Make instance → PHP reflection: inspects class
- Make instance → Resolve dependencies: resolves constructor args
- PHP reflection → Make instance: provides class metadata
- Resolve dependencies → Get instance: resolves class parameters
- Clear cache → Instance cache: removes instances
- Check binding → Bind mapping: checks mapping
- Check binding → Instance cache: checks instance
