PHPackages                             phpgt/servicecontainer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpgt/servicecontainer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpgt/servicecontainer
======================

Centralised container of a project's core objects.

v1.4.0(2mo ago)05.2k↑100%[2 PRs](https://github.com/PhpGt/ServiceContainer/pulls)3MITPHPPHP &gt;=8.3CI passing

Since May 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/PhpGt/ServiceContainer)[ Packagist](https://packagist.org/packages/phpgt/servicecontainer)[ GitHub Sponsors](https://github.com/sponsors/PhpGt)[ RSS](/packages/phpgt-servicecontainer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (20)Used By (3)

Centralised container of a project's core objects.
==================================================

[](#centralised-container-of-a-projects-core-objects)

When PHP applications have a lot of classes, it's important to use [dependency injection](https://martinfowler.com/articles/injection.html) techniques to keep your code maintainable and testable; rather than constructing objects within the functions they are used, pass the objects into the function via parameters.

Within this repository, a `Container` is an object that can be assigned pre-constructed instances of objects, and an `Injector` is an object that can automatically invoke other objects' methods with the matching instances from the Container.

There are no rules to how this repository should be used. You may want to have a single Container accessible to a single layer of your code, or you may want to have multiple Containers within your application to provide a different pool of object instances to different areas of your code.

This repository is used within [WebEngine](https://www.php.gt/webengine) to automatically invoke Page Logic functions, allowing the developer to have a single point within the application that is responsible for the object access of all first and third party classes.

---

[ ![Build status](https://camo.githubusercontent.com/0427f1b308dca14c4e51d297bb7b3650871215c028dec7af3c858f0b7ff6af81/68747470733a2f2f62616467652e7374617475732e7068702e67742f73657276696365636f6e7461696e65722d6275696c642e737667)](https://github.com/PhpGt/ServiceContainer/actions)[ ![Code quality](https://camo.githubusercontent.com/f934f2a28f88465d8f073b0f84b20ec3cb192713ecb47718e1581e8bfbf9d5b8/68747470733a2f2f62616467652e7374617475732e7068702e67742f73657276696365636f6e7461696e65722d7175616c6974792e737667)](https://app.codacy.com/gh/PhpGt/ServiceContainer)[ ![Code coverage](https://camo.githubusercontent.com/a99e922021107b7d4ae1ea485598d5783bd0cc4f3138c650ecc4cc6844e642bd/68747470733a2f2f62616467652e7374617475732e7068702e67742f73657276696365636f6e7461696e65722d636f7665726167652e737667)](https://app.codecov.io/gh/PhpGt/ServiceContainer)[ ![Current version](https://camo.githubusercontent.com/745e08f88333928fba8b2d34b4a198a38ff8eb188db0640f4e24bf057cfaea90/68747470733a2f2f62616467652e7374617475732e7068702e67742f73657276696365636f6e7461696e65722d76657273696f6e2e737667)](https://packagist.org/packages/PhpGt/ServiceContainer)[ ![PHP.G/ServiceContainer documentation](https://camo.githubusercontent.com/4baf3bb1b416757f1752ba968d6978106f9a2086c83e820efc753cf704cf171f/68747470733a2f2f62616467652e7374617475732e7068702e67742f73657276696365636f6e7461696e65722d646f63732e737667)](http://www.php.gt/servicecontainer)Proudly sponsored by
====================

[](#proudly-sponsored-by)

[JetBrains Open Source sponsorship program](https://www.jetbrains.com/community/opensource/)

[![JetBrains logo.](https://camo.githubusercontent.com/b5639e7738c6dfae9fe3f3e20175570b7376ce2577a772e09c25c2d4f14bf86e/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a6574627261696e732e737667)](https://www.jetbrains.com/community/opensource/)

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance86

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 75.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~134 days

Recently: every ~244 days

Total

14

Last Release

70d ago

Major Versions

v0.1.0 → v1.0.02021-08-29

PHP version history (3 changes)v0.1.0PHP &gt;=7.4

v1.0.0PHP &gt;=8.0

v1.3.4PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e42344b91ce4b91ab57875969f67a0a6a48de570a08bc65d673b06b72fd3a3f?d=identicon)[g105b](/maintainers/g105b)

---

Top Contributors

[![g105b](https://avatars.githubusercontent.com/u/358014?v=4)](https://github.com/g105b "g105b (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")

---

Tags

autowiringdependency-injectiondependency-injection-containermaintainabilityservice-containertestability

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpgt-servicecontainer/health.svg)

```
[![Health](https://phpackages.com/badges/phpgt-servicecontainer/health.svg)](https://phpackages.com/packages/phpgt-servicecontainer)
```

###  Alternatives

[illuminate/contracts

The Illuminate Contracts package.

705122.9M10.1k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31178.1M2.0k](/packages/illuminate-container)[symfony/type-info

Extracts PHP types information.

19951.9M114](/packages/symfony-type-info)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
