PHPackages                             techdata/context-di-bundle - 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. techdata/context-di-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

techdata/context-di-bundle
==========================

Symfony2 library to allow for context aware services.

1.0.0(10y ago)0152[5 issues](https://github.com/TechData/ContextDI/issues)MITPHPPHP &gt;=5.3.2

Since Jun 30Pushed 10y ago2 watchersCompare

[ Source](https://github.com/TechData/ContextDI)[ Packagist](https://packagist.org/packages/techdata/context-di-bundle)[ Docs](https://github.com/TechData/ContextDI)[ RSS](/packages/techdata-context-di-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

ContextDI
=========

[](#contextdi)

Allows for context dependency injection.

Concept
=======

[](#concept)

The concept is that there is often the need to know the context of the request. A context can be made up of one or more different facets such as User, Customer, Domain, GeoLocation, User IP, The presence of an outstanding quote, etc

The bundle builds on the existing Symfony DI system by allowing custom providers and consumers to be defined and then tagghed with what the need or what they can provide.

The system does not load the context until it is needed.

There is cache so that the context is not recomputed everytime a service wants to use it.

Consumer
========

[](#consumer)

A consumer service must implement the `TechData\ContextDiBundle\Interfaces\ContextConsumerInterface` interface and then be tagged with one or more tags of name "context\_consumer" which it wants to consume. The tag needs to have an attribute of "context\_name" which is a string that specifies which type of context it is looking for.

Provider
========

[](#provider)

A provider service must implement the `TechData\ContextDiBundle\Interfaces\ContextProviderInterface` interface and then be tagged with a single tag of name "context\_provider" which it wants to provide. The tag needs to have an attribute of "context\_name" which is a string that specifies which type of context being provided.

Cache
=====

[](#cache)

There is a cache which is checked prior to attempting to resolve the context. if the context is already available in the cache, it will be used. The default cache service caches the contexts per request.

Configuiration
==============

[](#configuiration)

The available types of context need to be specified (or "registered") in the main config file ("config.yml"). This is done by specifying the name of an interface or class which will be provided by the provider when the context is resolved. This ensures only certain contexts are available, and the context types are known to the consumer which will need to use them. Example.

```
tech_data_context_di:
    available_contexts:
        user: Vendor\Bundle\Interfaces\UserInterface
        customer: Vendor\Bundle\Entity\CustomerInterface

```

Optionally, the cache type can be switched to a different cache service which implements the `TechData\ContextDiBundle\Interfaces\ContextCacheInterface`. This can be done by specifying the cache service name in the config as shown below. This defaults to "tech\_data\_context\_di.cache.single\_request" which is a per request cache.

```
tech_data_context_di:
    available_contexts:
        user: Vendor\Bundle\Interfaces\UserInterface
        customer: Vendor\Bundle\Entity\CustomerInterface
    cache_service: some.custom.cache.service.name

```

Included Providers
==================

[](#included-providers)

Some providers for common use cases will be added soon.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3975d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dbe313eb9b1757cef60d1044789219d793f9f0cda2fea991f96905eb7b099f70?d=identicon)[westinpigott](/maintainers/westinpigott)

---

Top Contributors

[![westinpigott](https://avatars.githubusercontent.com/u/1909859?v=4)](https://github.com/westinpigott "westinpigott (4 commits)")

---

Tags

symfonyContext

### Embed Badge

![Health badge](/badges/techdata-context-di-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/techdata-context-di-bundle/health.svg)](https://phpackages.com/packages/techdata-context-di-bundle)
```

PHPackages © 2026

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