PHPackages                             lagdo/facades - 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. lagdo/facades

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

lagdo/facades
=============

Base classes to implement service facades.

v1.2.0(3mo ago)232.5k↓43.5%7BSD-3-ClausePHPPHP &gt;=8.0.0CI passing

Since Mar 30Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/lagdo/facades)[ Packagist](https://packagist.org/packages/lagdo/facades)[ Docs](https://github.com/lagdo/facades)[ RSS](/packages/lagdo-facades/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (7)

[![Build Status](https://github.com/lagdo/facades/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/lagdo/facades/actions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6c1f01f644bd99727b2b1b2bd4121c264dcd214cfc647846bd36dee63dea7056/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6167646f2f666163616465732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/lagdo/facades/?branch=main)[![StyleCI](https://camo.githubusercontent.com/03cee0417c1ece36bb5729bf61de59747a88bc351b69fe35296bfb908ec47923/68747470733a2f2f7374796c6563692e696f2f7265706f732f3935373135313537392f736869656c643f6272616e63683d6d61696e)](https://styleci.io/repos/957151579)[![codecov](https://camo.githubusercontent.com/e9bdb76ae53211db02ef8cd4ef635c7910ff31ca8c2494248dd900f4f45522ec/68747470733a2f2f636f6465636f762e696f2f67682f6c6167646f2f666163616465732f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4845524b433630434331)](https://codecov.io/gh/lagdo/facades)

[![Latest Stable Version](https://camo.githubusercontent.com/c59782ebb7093b237aa535c3e2a11f28e7bb81a8d15a8834ae1691dd32fcaf85/68747470733a2f2f706f7365722e707567782e6f72672f6c6167646f2f666163616465732f762f737461626c65)](https://packagist.org/packages/lagdo/facades)[![Total Downloads](https://camo.githubusercontent.com/f89ff9eab4e86b4121661e6245198682a4c2dcc68b200cb99aad491afc7b1f1a/68747470733a2f2f706f7365722e707567782e6f72672f6c6167646f2f666163616465732f646f776e6c6f616473)](https://packagist.org/packages/lagdo/facades)[![License](https://camo.githubusercontent.com/0ff2038e76502425a3469bc1b71dc1740af5e97a7035fbeed8ba9d392940c610/68747470733a2f2f706f7365722e707567782e6f72672f6c6167646f2f666163616465732f6c6963656e7365)](https://packagist.org/packages/lagdo/facades)

Base classes for service facades
================================

[](#base-classes-for-service-facades)

This package provides base classes for service facades implementations.

The goal of the separation between this package and the framework related ones is to make the facades portable across different frameworks. A service facade can be use without any change with various frameworks, provided that a package for this framework is available, or a `PSR-11` container can be provided.

The following packages are currently available:

- Symfony:
- Laravel:
- CakePHP:
- Yii:

### Facades definition

[](#facades-definition)

The `Lagdo\Facades\AbstractFacade` abstract class is the base class for user defined service facades.

```
namespace App\Facades;

use App\Services\MyService;
use Lagdo\Facades\AbstractFacade;

/**
 * @extends AbstractFacade
 */
class MyFacade extends AbstractFacade
{
    /**
     * @inheritDoc
     */
    protected static function getServiceIdentifier(): string
    {
        return MyService::class;
    }
}
```

If a given service doesn't need to be fetched from the container at each call, it can be saved in its facade class by using the `Lagdo\Facades\ServiceInstance` trait.

```
namespace App\Facades;

use App\Services\MyService;
use Lagdo\Facades\AbstractFacade;
use Lagdo\Facades\ServiceInstance;

/**
 * @extends AbstractFacade
 */
class MyFacade extends AbstractFacade
{
    use ServiceInstance;

    /**
     * @inheritDoc
     */
    protected static function getServiceIdentifier(): string
    {
        return MyService::class;
    }
}
```

Important

The `Lagdo\Facades\ServiceInstance` trait *must* be used in each service facade class, and not in a parent class. The same instance will be shared by all the classes inheriting the same base class using the trait, and the service facades will ot work as expected.

The service container will be called only once in the above example.

```
    MyFacade::myMethod1(); // Calls the service container
    MyFacade::myMethod2(); // Doesn't call the service container
    MyFacade::myMethod1(); // Doesn't call the service container
```

### Container setup

[](#container-setup)

The `Lagdo\Facades\ContainerWrapper` class gives access to the underlying container.

It needs to be provided with a `PSR-11` container, which will be done by the framework specific packages, but can also be done by the developer in case a package is not available.

```
use Lagdo\Facades\ContainerWrapper;

ContainerWrapper::setContainer($container);

$container = ContainerWrapper::getContainer();
```

### Provided facade and service

[](#provided-facade-and-service)

A default facade and a default service are provided for logging.

If the provided `PSR-11` container already has a `PSR-3` logger registered, then the `Lagdo\Facades\Logger` facade can be used.

```
use Lagdo\Facades\Logger;

Logger::info('This is an information');
```

A simple `PSR-3` logger implementation is also provided. It will return the local services, and revert to the already defined container for the other services.

```
use Lagdo\Facades\ContainerWrapper;
use Lagdo\Facades\Logger;

ContainerWrapper::registerLocalServices([
    'filename' => '/path/to/logs/dir/app',
    'extension' => '.log',
]);

// Log a message in the '/path/to/logs/dir/app.log' file.
Logger::info('This is an information');
```

Contribute
----------

[](#contribute)

- Issue Tracker: github.com/lagdo/facades/issues
- Source Code: github.com/lagdo/facades

License
-------

[](#license)

The package is licensed under the 3-Clause BSD license.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance78

Regular maintenance activity

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

Total

4

Last Release

118d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebb668d7515d81741c86e42cf3194f5623636fbb15dd5412e26ea8320865d229?d=identicon)[lagdo](/maintainers/lagdo)

---

Top Contributors

[![feuzeu](https://avatars.githubusercontent.com/u/15174329?v=4)](https://github.com/feuzeu "feuzeu (15 commits)")

---

Tags

phpService Facades

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lagdo-facades/health.svg)

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

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k447.1M8.9k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

706127.7M12.4k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31080.7M2.3k](/packages/illuminate-container)[symfony/type-info

Extracts PHP types information.

20062.9M225](/packages/symfony-type-info)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k41](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

744284.3k34](/packages/civicrm-civicrm-core)

PHPackages © 2026

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