33[ ![ PHP Version] ( https://img.shields.io/badge/php-%5E8.4-blue )] ( https://www.php.net/ )
44[ ![ License] ( https://img.shields.io/badge/license-MIT-green )] ( LICENSE )
55[ ![ Tests] ( https://img.shields.io/badge/tests-passing-brightgreen )] ( tests/ )
6+ [ ![ Coverage] ( https://img.shields.io/badge/coverage-report-brightgreen )] ( #testing )
67[ ![ CI] ( https://github.com/atomic-php/container/actions/workflows/ci.yml/badge.svg )] ( https://github.com/atomic-php/container/actions )
78[ ![ Codecov] ( https://codecov.io/gh/atomic-php/container/branch/main/graph/badge.svg )] ( https://codecov.io/gh/atomic-php/container )
89[ ![ Packagist] ( https://img.shields.io/packagist/v/atomic/container )] ( https://packagist.org/packages/atomic/container )
@@ -57,6 +58,8 @@ composer require atomic/container
5758
5859## Quick Start
5960
61+ ### Basic Usage
62+
6063``` php
6164<?php
6265
@@ -87,6 +90,8 @@ $uuid1 = $container->get('uuid');
8790$uuid2 = $container->get('uuid'); // different
8891```
8992
93+ Note: This package is framework‑agnostic and can be used with any PSR‑11 consumer.
94+
9095## Architecture
9196
9297### Core Components
@@ -99,6 +104,20 @@ $uuid2 = $container->get('uuid'); // different
99104└────────────────────┘ └───────────────────────┘
100105```
101106
107+ ### Compilation Process
108+
109+ 1 . Boot Time: Builder collects instances, factories and aliases and compiles them into an immutable container.
110+ 2 . Runtime: ` get() ` performs O(1) lookup with alias pre-resolution and lazy singleton caching.
111+ 3 . Caching: Shared factories are resolved once and cached on first use.
112+
113+ ``` php
114+ // This happens ONCE at boot:
115+ $container = $builder->compile();
116+
117+ // This happens MILLIONS of times at runtime:
118+ $service = $container->get('service'); // ⚡ Fast path
119+ ```
120+
102121### Resolution Model
103122
1041231 . ` alias(id) ` → resolve to final target (pre‑resolved at compile)
@@ -158,19 +177,67 @@ composer cs-check
158177
159178` composer test-coverage ` generates ` coverage.xml ` (Clover) used by CI; the workflow uploads it to Codecov for the badge/report.
160179
161- ## Benchmarks
180+ ## Benchmarking
181+
182+ Measure performance with the built-in benchmark suite:
162183
163184``` bash
185+ # Run all benchmarks
164186composer benchmark
187+
188+ # View detailed performance metrics
189+ php benchmarks/run-benchmarks.php
190+ ```
191+
192+ ### Benchmark Results
193+
194+ ``` text
195+ Container Benchmark:
196+ benchGetInstance : 3,409,676 ops/sec (0.000 ms/op)
197+ benchGetSingleton : 3,419,738 ops/sec (0.000 ms/op)
198+ benchGetFactory : 1,877,929 ops/sec (0.001 ms/op)
199+ benchGetAlias : 3,254,276 ops/sec (0.000 ms/op)
200+ benchHasHit : 3,323,349 ops/sec (0.000 ms/op)
201+ benchHasMiss : 3,132,513 ops/sec (0.000 ms/op)
202+
203+ Compile Benchmark:
204+ benchCompile5 : 450,885 ops/sec (0.002 ms/op)
205+ benchCompile20 : 139,451 ops/sec (0.007 ms/op)
165206```
166207
167- Includes:
208+ ## Code Quality
209+
210+ Maintain code quality with included tools:
211+
212+ ``` bash
213+ # Check code style
214+ composer cs-check
215+
216+ # Fix code style
217+ composer cs-fix
218+
219+ # Run static analysis
220+ composer psalm
221+
222+ # Run all quality checks
223+ composer qa
224+ ```
225+
226+ ## Contributing
227+
228+ We welcome contributions! Please see [ CONTRIBUTING.md] ( CONTRIBUTING.md ) for details.
229+
230+ ## Changelog
231+
232+ See [ CHANGELOG.md] ( CHANGELOG.md ) for release notes and version history.
233+
234+ ## License
168235
169- - ` ContainerBenchmark ` — get()/has() performance for instances, singletons, factories, aliases
170- - ` ContainerCompileBenchmark ` — compile time with small/medium registration sets
236+ This project is licensed under the MIT License — see [ LICENSE] ( LICENSE ) .
171237
172- ## Notes
238+ ### Test Coverage
173239
174- - Immutable runtime container: build everything up front via the builder, then share the compiled instance.
175- - Aliases are cycle‑checked during compilation; self‑aliasing and cycles throw.
176- - The container is intentionally lean and unopinionated; add higher‑level features (e.g., providers/autowiring) in your app layer if desired.
240+ - Registrations and aliasing (including chains and cycle detection)
241+ - Singleton caching and factory creation
242+ - Error propagation (wrapping into ContainerException)
243+ - Immutability of compiled container
0 commit comments