PHPackages                             geekcell/container-facade - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. geekcell/container-facade

AbandonedArchivedLibrary[PSR &amp; Standards](/categories/psr-standards)

geekcell/container-facade
=========================

A simple library for creating static facades for PSR-11 compatible container services.

1.0.0(3y ago)111.1k↑60%1[1 PRs](https://github.com/geekcell/container-facade/pulls)3MITPHP

Since Feb 18Pushed 2y ago2 watchersCompare

[ Source](https://github.com/geekcell/container-facade)[ Packagist](https://packagist.org/packages/geekcell/container-facade)[ RSS](/packages/geekcell-container-facade/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (3)

container-facade
================

[](#container-facade)

[![Unit tests workflow status](https://github.com/geekcell/container-facade/actions/workflows/tests.yaml/badge.svg)](https://github.com/geekcell/container-facade/actions/workflows/tests.yml) [![Coverage](https://camo.githubusercontent.com/e84bef8d5d4f857f404e9dcee14c2ea8e591199ff9d4e7d91ad8bd101eb7535b/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6765656b63656c6c5f636f6e7461696e65722d666163616465266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=geekcell_container-facade) [![Bugs](https://camo.githubusercontent.com/c494c8a388732e89f3aa04adb3e4d77bc6dd86ab67a84196ed26903856ff2f52/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6765656b63656c6c5f636f6e7461696e65722d666163616465266d65747269633d62756773)](https://sonarcloud.io/summary/new_code?id=geekcell_container-facade) [![Maintainability Rating](https://camo.githubusercontent.com/96f473549a28f59f88362cef9951a777d6bc1780dc8378a5cd5a94da342a2e86/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6765656b63656c6c5f636f6e7461696e65722d666163616465266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=geekcell_container-facade) [![Quality Gate Status](https://camo.githubusercontent.com/54ef00e793f6dd6b5241fe6ee7ae85ff96ae8620d8a9786dedbc2d8d520d51d8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6765656b63656c6c5f636f6e7461696e65722d666163616465266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=geekcell_container-facade)

A standalone PHP library heavily inspired by [Laravel's Facade](https://laravel.com/docs/master/facades) implementation, which can be used with any [PSR-11 compatible](https://www.php-fig.org/psr/psr-11/) dependency injection container (DIC) such as (the ones used by) [PHP-DI](https://php-di.org/), [Symfony](https://symfony.com/), [Pimple](https://github.com/silexphp/Pimple), or [Slim](https://www.slimframework.com/).

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

[](#installation)

To use this package, require it with Composer.

```
composer install geekcell/container-facade
```

Motivation
----------

[](#motivation)

Although rare, there are situations when you want to obtain a container service without dependency injection. An example would be the [`AggregateRoot` pattern](https://martinfowler.com/bliki/DDD_Aggregate.html), which allows [dispatching domain events](https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation) directly from the aggregate, which is usually created directly and not via a DIC. In such a case, a corresponding (static) service facade can provide a comparable convenience as a singleton, but without the inherent [disadvantages of the singleton pattern](https://stackoverflow.com/a/138012).

Usage
-----

[](#usage)

Let's imagine you have a `Logger` service inside your DIC of choice that logs a message into a file.

```
