PHPackages                             passchn/cakephp-simple-di - 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. [Framework](/categories/framework)
4. /
5. passchn/cakephp-simple-di

ActiveCakephp-plugin[Framework](/categories/framework)

passchn/cakephp-simple-di
=========================

Simple Dependency Injection plugin for CakePHP

v3.4.1(1y ago)0641MITPHPPHP ^8.2

Since Feb 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/passchn/cakephp-simple-di)[ Packagist](https://packagist.org/packages/passchn/cakephp-simple-di)[ RSS](/packages/passchn-cakephp-simple-di/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (13)Used By (1)

SimpleDI plugin for CakePHP
===========================

[](#simpledi-plugin-for-cakephp)

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

The recommended way to install composer packages is:

```
composer require passchn/cakephp-simple-di
```

Load the plugin:

```
bin/cake plugin load Passchn/SimpleDI
```

Usage
-----

[](#usage)

In your `Application.php`:

```
public function services(ContainerInterface $container): void
{
    Configure::load('app_di');

    DIManager::create($container)
        // to add individual services:
        ->addServices(Configure::readOrFail('DI.services'))
        /**
        * to collect multiple services, define a module:
        * @see \Passchn\SimpleDI\Module\Module\ModuleInterface
        */
        ->addModules(Configure::readOrFail('DI.modules'))
        /**
        * a plugin can define multiple modules:
        * @see \Passchn\SimpleDI\Module\Plugin\PluginInterface
        */
        ->addPlugin(SomePlugin::class);
}
```

Then, define Factories/Modules in your `app_di.php`:

```
return [
    'DI' => [
        'services' => [
            NewsletterService::class => NewsletterServiceFactory::class,
            CheckoutService::class => CheckoutServiceFactory::class,
            PaymentService::class => fn () => new PaymentService(),
        ],
        'modules' => [
            MyModule::class,
        ],
    ],
];
```

Factories should be Invokables or class-strings of Invokables.

You can then use the Service e.g. in Controller Actions:

```
class ExamplesController {

    public function someAction(NewsletterService $service): Response
    {
        $service->doSomething();
    }
}
```

If real DI is not possible, e.g. in ViewCells, you can use the `ServiceLocator` to receive the container or Services.

```
Passchn\SimpleDI\Module\ServiceLocator\ServiceLocator::get(NewsletterService::class); // the service
```

This only works if you loaded the plugin or registered the container yourself, e.g.:

```
// in your Application::services()
ServiceLocator::setContainer($container);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~16 days

Recently: every ~3 days

Total

12

Last Release

637d ago

Major Versions

v1.2.0 → v2.0.12024-08-04

v2.0.0 → v3.0.02024-08-04

PHP version history (2 changes)v1.0.0PHP &gt;=8.1

v2.0.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77938819?v=4)[Pascal Schneider](/maintainers/passchn)[@passchn](https://github.com/passchn)

---

Top Contributors

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

---

Tags

cakephpcakephp4cakephp5dependency-injectionphpphp82

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/passchn-cakephp-simple-di/health.svg)

```
[![Health](https://phpackages.com/badges/passchn-cakephp-simple-di/health.svg)](https://phpackages.com/packages/passchn-cakephp-simple-di)
```

###  Alternatives

[cakephp/debug_kit

CakePHP Debug Kit

86514.0M138](/packages/cakephp-debug-kit)[cakephp/bake

Bake plugin for CakePHP

11211.2M158](/packages/cakephp-bake)[friendsofcake/bootstrap-ui

Bootstrap front-end framework support for CakePHP

3492.1M32](/packages/friendsofcake-bootstrap-ui)[cakephp/app

CakePHP skeleton app

3831.7M1](/packages/cakephp-app)[cakephp/localized

CakePHP Localized Plugin

218595.6k5](/packages/cakephp-localized)[cakephp/acl

Acl Plugin for CakePHP framework

109553.9k15](/packages/cakephp-acl)

PHPackages © 2026

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