PHPackages                             wok/services - 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. wok/services

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

wok/services
============

WOK Service provider and dependency injection

v1.1.1(9y ago)0571MITPHP

Since Sep 27Pushed 9y ago1 watchersCompare

[ Source](https://github.com/web-operational-kit/services)[ Packagist](https://packagist.org/packages/wok/services)[ RSS](/packages/wok-services/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (6)Used By (1)

Services
========

[](#services)

This library is lightweight **dependency injection**.

[![SensioLabsInsight](https://camo.githubusercontent.com/32801f2c3eb412c839e6921b271096352ce63ed61522251a5448232e2c0bf80a/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38313962373132662d396332362d346430642d623234612d3266656364393834623064332f6269672e706e67)](https://insight.sensiolabs.com/projects/819b712f-9c26-4d0d-b24a-2fecd984b0d3)

**Diclaimer :** This component is part of the [WOK](https://github.com/web-operational-kit/) (Web Operational Kit) framework. It however can be used as a standalone library.

Install
-------

[](#install)

It is recommanded to install that component as a dependency using [Composer](https://getcomposer.org/) :

```
composer require wok/services

```

You're also free to get it with [git](https://git-scm.com/) or by [direct download](https://github.com/web-operational-kit/router/archive/master.zip) while this package has no dependencies.

```
git clone https://github.com/web-operational-kit/services.git

```

Features
--------

[](#features)

While a lot of dependencies injectors have been developed (such as [pimple/pimple](https://packagist.org/packages/pimple/pimple), or [league/container](https://packagist.org/packages/league/container)), this library roadmap has some specificities :

- The Services component is a dependency injector (usual).
- Depencies instances MUST be cached throughout the Services object life (that's the dependency injection pattern).
- **Dependencies instances constructors CAN accept parameters without having any trouble with the previous points.**

Let's see this [in usage](#usage).

Usage
-----

[](#usage)

Basic usage
-----------

[](#basic-usage)

```
use \WOK\Services\Services;
$services = new Services();

// Sample with Doctrine/Cache as `cache` service.
$services->addService('cache', function() {

    return new \Doctrine\Common\Cache\FilesystemCache(
        './var/cache');

});

// Far far away ...

// Retrieve the service
$cache = $services->getService('cache');
```

With parameters
---------------

[](#with-parameters)

```
use \WOK\Services\Services;
$services = new Services();

// Sample with Symfony/Translation as `translator` service and the locale code as parameter
$services->addService('translator', function($locale) {

    $translator = new \Symfony\Component\Translation\Translator($locale);
    $translator->addLoader('ini', new \Symfony\Component\Translation\Loader\IniFileLoader());

    $files = new DirectoryIterator($path);
    foreach($files as $resource) {

        if($resource->getExtension() != 'ini') {
            continue;
        }

        // Only accepted files as `domain.locale.(ini|yml)`
        $basename = $resource->getBasename();
        $domain = mb_substr($basename, 0, mb_strpos($basename, '.'));

        $translator->addResource($resource->getExtension(), $resource->getPathname(), $locale, $domain);

    }

    return $translator;

});

// Far far away ...

$translator = $services->getService('translator', array('fr_FR'));
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

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

Total

4

Last Release

3389d ago

Major Versions

v0.2.0 → v1.0.02016-11-10

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2820221?v=4)[Sébastien ALEXANDRE](/maintainers/graphidev)[@graphidev](https://github.com/graphidev)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/wok-services/health.svg)

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

###  Alternatives

[breadlesscode/neos-blog

Ready to use blog package

161.4k](/packages/breadlesscode-neos-blog)[edofre/yii2-slider-pro

Yii2 widget for slider-pro

112.7k](/packages/edofre-yii2-slider-pro)

PHPackages © 2026

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