PHPackages                             lionsad/service\_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. [Framework](/categories/framework)
4. /
5. lionsad/service\_container

ActiveDrupal-module[Framework](/categories/framework)

lionsad/service\_container
==========================

Service Container based on CTools plugins with Symfony Integration

1.0.0-beta5(10y ago)51.0k2GPL-2.0+PHPPHP &gt;=5.3.10

Since Jun 10Pushed 9y ago3 watchersCompare

[ Source](https://github.com/LionsAd/service_container)[ Packagist](https://packagist.org/packages/lionsad/service_container)[ Docs](https://www.drupal.org/project/service_container)[ RSS](/packages/lionsad-service-container/feed)WikiDiscussions 7.x-1.x Synced 1mo ago

READMEChangelog (5)DependenciesVersions (9)Used By (0)

service\_container
==================

[](#service_container)

[![Build Status](https://camo.githubusercontent.com/34861a54b0e25b61b0c7f19dece18a3e14fd10491cae497fb2a11187c04bfc59/68747470733a2f2f7472617669732d63692e6f72672f4c696f6e7341642f736572766963655f636f6e7461696e65722e7376673f6272616e63683d372e782d312e78)](https://travis-ci.org/LionsAd/service_container)[![Coverage Status](https://camo.githubusercontent.com/928cd2c4bde8cd213434c968adbda38b48e99ca45518bfe352d693264917faf3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f4c696f6e7341642f736572766963655f636f6e7461696e65722f62616467652e706e673f6272616e63683d372e782d312e78)](https://coveralls.io/r/LionsAd/service_container?branch=7.x-1.x)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/465544319a30ab85047c955fe59fa4797688d9397d7384d94a34602bb51b5e3f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c696f6e7341642f736572766963655f636f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d372e782d312e78)](https://scrutinizer-ci.com/g/LionsAd/service_container/?branch=7.x-1.x)[!\[Gitter\](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/LionsAd/service_container?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Versions
========

[](#versions)

[![Latest Stable Version](https://camo.githubusercontent.com/93abb5eef78811aff31a472ee2f90b021382d32831dd1f779e48551434dd3ce5/68747470733a2f2f706f7365722e707567782e6f72672f6c696f6e7361642f736572766963655f636f6e7461696e65722f762f737461626c65)](https://packagist.org/packages/lionsad/service_container) [![Total Downloads](https://camo.githubusercontent.com/16a44335133a89bb7ed210e15e693fa0d29e4d8fcebd4e4a38827d612250fa65/68747470733a2f2f706f7365722e707567782e6f72672f6c696f6e7361642f736572766963655f636f6e7461696e65722f646f776e6c6f616473)](https://packagist.org/packages/lionsad/service_container) [![Latest Unstable Version](https://camo.githubusercontent.com/74f11c0b29d40b081a5ed26e27ed9c0ed23be01e366eee48a7ba5938bc174b6a/68747470733a2f2f706f7365722e707567782e6f72672f6c696f6e7361642f736572766963655f636f6e7461696e65722f762f756e737461626c65)](https://packagist.org/packages/lionsad/service_container) [![License](https://camo.githubusercontent.com/e3608ae8220af27881f7931414594d429923552d370ba234c55563b92395be6a/68747470733a2f2f706f7365722e707567782e6f72672f6c696f6e7361642f736572766963655f636f6e7461696e65722f6c6963656e7365)](https://packagist.org/packages/lionsad/service_container)

Service Container is an API module based on [ctools](https://www.drupal.org/project/ctools) to enable a Drupal 7 quick and easy lightweight service container with 100% unit test coverage.

It is very similar in syntax to a Symfony container, but was written from scratch as a symfony dependency was not wanted - using some of Drupal 8 Core and Component directly. They will likely depend on a drupal8core project in the future - but for now the copy is fine.

This allows to use an extensible service container (like in Drupal 8) and write modules in Drupal 7 as if they were using Drupal 8.

The main benefit is being able to use unit testing but also to write Drupal 7 module with Drupal 8 style of coding in mind.

The module uses PHP Unit and travis.yml, but the tests and a composer.json are isolated in the tests/ directory, so no vendor or composer multi map is needed by default.

It was originally written for the render\_cache module, but since then others have expressed interest in using it, so it was split it out and made a dependency of render\_cache instead.

You need:

- [registry\_autoload](https://www.drupal.org/project/registry_autoload)

or any other PSR-4 autoloader.

### Registering CTools plugins

[](#registering-ctools-plugins)

By default the service\_container supports CTools discovery, to register your plugins all you need to do is:

```
    $parameters['ctools_plugins_auto_discovery']['render_cache'] = TRUE
```

And you can then get a plugin via:

```
    $rcc = \Drupal::service('render_cache.controller')->createInstance('block');
```

Because the plugin managers implement the whole discovery interface, you can get all definitions with ease.

```
  $plugins = \Drupal::service('render_cache.controller')->getDefinitions();
```

Your plugin itself looks like:

cat modules/render\_cache\_block/src/RenderCache/Controller/block.inc

```
$plugin = array(
  'class' => "\\Drupal\\render_cache_block\\RenderCache\\Controller\\BlockController",
  'arguments' => array('@render_stack', '@render_cache.cache'),
);
```

So you can use normal container parameter syntax.

### Provides the following services:

[](#provides-the-following-services)

- module handler ('module\_handler') and module installer ('module\_installer')
- service container ('service\_container')
- database ('database')
- key value store ('keyvalue', 'keyvalue.database')
- variable, a wrapper for variable\_get() / variable\_set()
- A lock ('lock')
- A wrapper for url() / l() ('url\_generator', 'link\_generator')
- Flood, a wrapper for the flood mechanisms
- Messenger, a wrapper for displaying messages
- Drupal 7 Legacy, a wrapper for accessing the Drupal 7 legacy functions.
- More to come...

### Testing

[](#testing)

- service\_container is tested via PHPUnit for code correctness. (run ./tests/run-tests.sh)
- service\_container is tested via simpletest for integration with Drupal. (run ./tests/run-simpletests.sh)
- service\_container is tested via PHPUnit for code coverage. (run ./tests/run-coverage.sh)

### List of Drupal 8 core services that we've altered

[](#list-of-drupal-8-core-services-that-weve-altered)

See the file HACK.md for more details.

### Examples of modules that use this module

[](#examples-of-modules-that-use-this-module)

- [render\_cache 7.x-2.x](https://www.drupal.org/project/render_cache)
- [openlayers 7.x-3.x](https://www.drupal.org/project/openlayers)
- [vardumper 7.x-1.x](https://www.drupal.org/project/vardumper)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

5

Last Release

3959d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/92a294a0cf0dd293e99686bd29fd61744319b5fcb0b1ca22dab265abaf38808b?d=identicon)[LionsAd](/maintainers/LionsAd)

---

Top Contributors

[![fabianx-ai](https://avatars.githubusercontent.com/u/354804?v=4)](https://github.com/fabianx-ai "fabianx-ai (210 commits)")[![LionsAd](https://avatars.githubusercontent.com/u/354804?v=4)](https://github.com/LionsAd "LionsAd (210 commits)")[![dawehner](https://avatars.githubusercontent.com/u/29678?v=4)](https://github.com/dawehner "dawehner (88 commits)")[![drupol](https://avatars.githubusercontent.com/u/252042?v=4)](https://github.com/drupol "drupol (17 commits)")[![das-peter](https://avatars.githubusercontent.com/u/177531?v=4)](https://github.com/das-peter "das-peter (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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