PHPackages                             prestashop/module-lib-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. prestashop/module-lib-service-container

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

prestashop/module-lib-service-container
=======================================

Service container to use on prestashop modules

v2.0(3y ago)8170.6k—8.9%2[1 issues](https://github.com/PrestaShopCorp/module-lib-service-container/issues)4AFL-3.0PHPPHP &gt;=5.6.0

Since Sep 8Pushed 3y ago4 watchersCompare

[ Source](https://github.com/PrestaShopCorp/module-lib-service-container)[ Packagist](https://packagist.org/packages/prestashop/module-lib-service-container)[ RSS](/packages/prestashop-module-lib-service-container/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (12)Used By (4)

PrestaShop Service Container for Modules
========================================

[](#prestashop-service-container-for-modules)

This repository includes the service container from Symfony that you can use in your PrestaShop Module.

Pre-requisites
--------------

[](#pre-requisites)

You should install this library only on a PrestaShop environment and with PHP 5.6.0 minimum.

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

[](#installation)

```
# PrestaShop 1.7+
composer require prestashop/module-lib-service-container

# PrestaShop 1.6
composer require prestashop/module-lib-service-container
composer require symfony/config:^3.4 symfony/dependency-injection:^3.4 symfony/expression-language:^3.4 symfony/yaml:^3.4
```

When this project is successfully added to your dependencies, you can add the new ServiceContainer to your module and use it. PrestaShop runs with Symfony components from version 1.7, so dependancies are not required anymore here. I you plan to run your module on PrestaShop, Symfony dependencies must be required separately.

Usage
-----

[](#usage)

To use this library, it's simple :

- First, declare your new service Container in your root module PHP file (like mymodule.php at your root project folder) :

```
    /**
     * @var ServiceContainer
     */
    private $serviceContainer;

```

- And instantiate it in the constructor with the module name and its local path :

```
$this->serviceContainer = new ServiceContainer($this->name, $this->getLocalPath());

```

- You can add a new function on your root module PHP file, like getService, to retrieve your service name in the new service container :

```
    /**
     * @param string $serviceName
     *
     * @return mixed
     */
    public function getService($serviceName)
    {
        return $this->serviceContainer->getService($serviceName);
    }

```

- Then, you have to declare your service in the services.yml file. You must declare your services in the config/ folder. From Symfony 4, services must be explicitely declared as public to be loaded with the method `getService()`;

We split the services in two folders in the config : /front and /admin folders. So the tree should be like :

```
/mymodule
    /config
        /front
            services.yml
        /admin
            services.yml
        common.yml

```

- Of course, you can include a common file, with common services that are use in front and admin project by an import in the services.yml file :

```
imports:
  - { resource: ../common.yml }

```

Now you can add your services in the services.yml like you were in a Symfony project ;)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.1% 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 ~108 days

Recently: every ~158 days

Total

7

Last Release

1429d ago

Major Versions

1.4.0 → v2.02022-06-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15106407?v=4)[Jarvis](/maintainers/ps-jarvis)[@ps-jarvis](https://github.com/ps-jarvis)

---

Top Contributors

[![yohanBarilleau](https://avatars.githubusercontent.com/u/5693379?v=4)](https://github.com/yohanBarilleau "yohanBarilleau (17 commits)")[![Matt75](https://avatars.githubusercontent.com/u/5262628?v=4)](https://github.com/Matt75 "Matt75 (9 commits)")[![Quetzacoalt91](https://avatars.githubusercontent.com/u/6768917?v=4)](https://github.com/Quetzacoalt91 "Quetzacoalt91 (3 commits)")[![guillaumeArgiles](https://avatars.githubusercontent.com/u/5442678?v=4)](https://github.com/guillaumeArgiles "guillaumeArgiles (2 commits)")[![zalexki](https://avatars.githubusercontent.com/u/3863527?v=4)](https://github.com/zalexki "zalexki (1 commits)")

---

Tags

composerpackagemodulesprestashop

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/prestashop-module-lib-service-container/health.svg)

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

###  Alternatives

[jean85/pretty-package-versions

A library to get pretty versions strings of installed dependencies

1.3k289.5M63](/packages/jean85-pretty-package-versions)[composer/satis

Simple Repository Generator

3.3k1.4M17](/packages/composer-satis)[fxp/composer-asset-plugin

NPM/Bower Dependency Manager for Composer

8894.8M41](/packages/fxp-composer-asset-plugin)[foxy/foxy

Fast, reliable, and secure NPM/Yarn/pnpm bridge for Composer

177287.5k25](/packages/foxy-foxy)[netojose/laravel-bootstrap-4-forms

Bootstrap 4 form builder for Laravel 5

182115.3k](/packages/netojose-laravel-bootstrap-4-forms)[cpx/cpx

Run any command from any composer package, even if it's not installed in your project.

40410.9k1](/packages/cpx-cpx)

PHPackages © 2026

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