PHPackages                             sefra/container - 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. sefra/container

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

sefra/container
===============

service container for wordpress plugins and themes

v1.0.1(4mo ago)28MITPHPPHP ^8.1

Since Jan 6Pushed 4mo agoCompare

[ Source](https://github.com/YoussefACHCHIRAJ/sefra-container)[ Packagist](https://packagist.org/packages/sefra/container)[ RSS](/packages/sefra-container/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Sefra Container
===============

[](#sefra-container)

A lightweight **service container** for WordPress plugins and themes, inspired by Laravel's and other modern PHP frameworks’ dependency injection containers.
It allows you to **bind classes, singletons, and closures**, and automatically resolves dependencies via constructor injection.

Purpose
-------

[](#purpose)

This container is a core part of the [Sefra WordPress Plugin Starter Kit](https://github.com/YoussefACHCHIRAJ/sefra-plugin-starter), providing dependency injection and service management for plugins.

Documentation
-------------

[](#documentation)

If you have a WordPress plugin and want to integrate Sefra Container to manage dependency injection, check this guide: [How To Use Sefra Container](https://achchiraj.dev/plugins/sefra-container/how-to-use)

If you’re starting a new plugin, you might find this starter kit useful:

- repository: [Sefra WordPress Plugin Starter Kit](https://github.com/YoussefACHCHIRAJ/sefra-plugin-starter)
- documentation on it built: [documentation](https://achchiraj.dev/plugins/sefra-starter)

Installation
------------

[](#installation)

Use Composer to install:

```
composer require sefra/container
```

Usage
-----

[](#usage)

```
use Sefra\Core\Container;

// Get container instance
$container = Container::getInstance();

// Bind a class
$container->bind(App\Services\MyService::class);

// Bind a singleton
$container->singleton(App\Services\MySingletonService::class);

// Resolve an instance
$service = $container->get(App\Services\MyService::class);
```

Constructor Injection
---------------------

[](#constructor-injection)

Dependencies are automatically resolved:

```
class Logger {
    public function log($message) { /* ... */ }
}

class Mailer {
    public function __construct(Logger $logger) { $this->logger = $logger; }
}

$mailer = $container->resolve(Mailer::class); // Logger is injected automatically
```

Restrictions
------------

[](#restrictions)

Injecting the container itself into services is forbidden to prevent tight coupling.

Circular dependencies are detected and will throw an exception.

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance76

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Every ~0 days

Total

2

Last Release

131d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b2ef1180e3555344417f8f5d5717f20c8e9fa35f5de9badf85771cfa9c88925?d=identicon)[YoussefACHCHIRAJ](/maintainers/YoussefACHCHIRAJ)

---

Top Contributors

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

---

Tags

packagistphp8wordpress

### Embed Badge

![Health badge](/badges/sefra-container/health.svg)

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

PHPackages © 2026

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