PHPackages                             acelaya/slim-container-sm - 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. acelaya/slim-container-sm

AbandonedArchivedLibrary[Framework](/categories/framework)

acelaya/slim-container-sm
=========================

A Slim framework container wrapping a ZF2 ServiceManager

v2.0.0(10y ago)33821[1 issues](https://github.com/acelaya/slim-container-sm/issues)MITPHPPHP ^5.5|^7.0

Since Jan 18Pushed 10y ago2 watchersCompare

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

READMEChangelogDependencies (4)Versions (8)Used By (0)

Slim Container - ServiceManager
===============================

[](#slim-container---servicemanager)

[![Build Status](https://camo.githubusercontent.com/9a43e7a88d924804439426756dc239b3dd8423fab5b5be3da5eb2307fb59ccf5/68747470733a2f2f7472617669732d63692e6f72672f6163656c6179612f736c696d2d636f6e7461696e65722d736d2e737667)](https://travis-ci.org/acelaya/slim-container-sm)[![Code Coverage](https://camo.githubusercontent.com/64b01d2926131b3ab55558540535d94f94a8b342f13d460eb44bd58410e8f091/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6163656c6179612f736c696d2d636f6e7461696e65722d736d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/acelaya/slim-container-sm/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/74ea5b29b958f73b28803861b5cf8d5d4530c6147f07523a55e6e17abdf74ed3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6163656c6179612f736c696d2d636f6e7461696e65722d736d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/acelaya/slim-container-sm/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/92798787a07c8a41afd4775339f9606f3ea93cee50066763f53cb1b1cde4b402/68747470733a2f2f706f7365722e707567782e6f72672f6163656c6179612f736c696d2d636f6e7461696e65722d736d2f762f737461626c652e706e67)](https://packagist.org/packages/acelaya/slim-container-sm)[![Total Downloads](https://camo.githubusercontent.com/9f3887e9602e3dab4e0ef7910861df460104b3f5e6aa57c9f859712729349ffb/68747470733a2f2f706f7365722e707567782e6f72672f6163656c6179612f736c696d2d636f6e7461696e65722d736d2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/acelaya/slim-container-sm)[![License](https://camo.githubusercontent.com/00fe47aeaea2bcb57b2cc8b1dead7aec8e723955ff871c7b10335e1450aa60b2/68747470733a2f2f706f7365722e707567782e6f72672f6163656c6179612f736c696d2d636f6e7461696e65722d736d2f6c6963656e73652e706e67)](https://packagist.org/packages/acelaya/slim-container-sm)

A Slim framework v2 container wrapping a Zend ServiceManager v3 so that services can be fetched from it.

> Current stable release depends on version 3 of the ServiceManager. If you need to use the version 2, install v1 of this component.

### Installation

[](#installation)

Install it with composer. Just run this.

```
composer require acelaya/slim-container-sm

```

### Usage

[](#usage)

This library provides a simple class, the `Acelaya\SlimContainerSm\Container` which extends `Slim\Helper\Set` and wraps an instance of a ServiceManager (which can be injected on it or lazy loaded).

By replacing Slim's container object by this one you can make Slim framework to fetch services from the ServiceManager, which is much more advanced and configurable.

```
use Acelaya\SlimContainerSm\Container;
use Slim\Slim;
use Vendor\ComplexClass;
use Vendor\MyAbstractFactory;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\ServiceManager\ServiceManager;

// Create a ServiceManager that is going to be used by the application and add some services to it
$sm = new ServiceManager([
    'factories' => [
        'complex_service' => function ($sm) {
            // Do stuff...

            return new ComplexClass();
        },
        'foo_invokable' => InvokableFactory::class,
    ],
    'abstract_factories' => [
        MyAbstractFactory::class
    ],
    'aliases' => [
        'foo' => 'foo_invokable'
    ]
]);
// Inject the ServiceManager in the new container
$container = new Container($sm);

// Create Slim object which will initialize its container
$app = new Slim();
// Inject default Slim services into our container
$container->consumeSlimContainer($app->container);
// Override Slim's container with the new one
$app->container = $container;
```

Once this is done, Slim will continue working with the new container as its own, and you can create more complex services using the ServiceManager.

This library is very useful with [rka-slim-controller](https://github.com/akrabat/rka-slim-controller) and [slimcontroller](https://github.com/fortrabbit/slimcontroller), both of them libraries that allow to create controllers in Slim framework as a service. In combination with this, you will be able to register Controllers in a ServiceManager.

### Invalid methods

[](#invalid-methods)

Because of the way the ServiceManager works, there are methods in `Slim\Helper\Set` that can't be used. These are the methods `all`, `keys`, `count` and `getIterator`. Those methods will throw a `Acelaya\SlimContainerSm\Exception\BadMethodCallException`. This makes the `Acelaya\SlimContainerSm\Container` not iterable.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Recently: every ~92 days

Total

6

Last Release

3760d ago

Major Versions

v0.1.3 → v1.0.02015-11-26

v1.0.0 → v2.0.02016-01-24

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

v1.0.0PHP &gt;=5.5.0

v2.0.0PHP ^5.5|^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/73480af83259e096d154a8c4333e550c186b28ccb7a0d11f537b9aa57ad35392?d=identicon)[acelaya](/maintainers/acelaya)

---

Top Contributors

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

---

Tags

dependency-injectionslimdiczf2Zend Framework

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/acelaya-slim-container-sm/health.svg)

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

###  Alternatives

[rdlowrey/auryn

Auryn is a dependency injector for bootstrapping object-oriented PHP applications.

7262.2M76](/packages/rdlowrey-auryn)[slim/twig-view

Slim Framework 4 view helper built on top of the Twig 3 templating component

3708.0M210](/packages/slim-twig-view)[mathmarques/smarty-view

Slim Framework 4 view helper built on top of the Smarty templating component

24134.7k1](/packages/mathmarques-smarty-view)[projek-xyz/slim-plates

Render your Slim 3 application views using Plates template engine.

2678.2k3](/packages/projek-xyz-slim-plates)[kitchenu/slim-debugbar

PHP Debugbar integration for Slim 3

1217.1k3](/packages/kitchenu-slim-debugbar)

PHPackages © 2026

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