PHPackages                             lagdo/laravel-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. [Framework](/categories/framework)
4. /
5. lagdo/laravel-facades

ActiveLibrary[Framework](/categories/framework)

lagdo/laravel-facades
=====================

Call Laravel services using facades.

v1.0.0(1y ago)03473BSD-3-ClausePHP

Since Mar 31Pushed 1y ago1 watchersCompare

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/375239c9d900df27b346f841f9e13247ea2955814ec8381c7cb9c2bd09e78da5/68747470733a2f2f706f7365722e707567782e6f72672f6c6167646f2f6c61726176656c2d666163616465732f762f737461626c65)](https://packagist.org/packages/lagdo/laravel-facades)[![Total Downloads](https://camo.githubusercontent.com/be33dba92389d71367168090332a555ee52eaad6cb4864e3a6dc3c6ed6f2e612/68747470733a2f2f706f7365722e707567782e6f72672f6c6167646f2f6c61726176656c2d666163616465732f646f776e6c6f616473)](https://packagist.org/packages/lagdo/laravel-facades)[![License](https://camo.githubusercontent.com/87c82328700fe087d7d66b50652d8e55ee519a82d49aee69ce49c869c6f11300/68747470733a2f2f706f7365722e707567782e6f72672f6c6167646f2f6c61726176656c2d666163616465732f6c6963656e7365)](https://packagist.org/packages/lagdo/laravel-facades)

Facades for Laravel services
============================

[](#facades-for-laravel-services)

With this package, Laravel services can be called using service facades, with static method syntax.

Note

It may be surprising to implement service facades for Laravel, since the same feature is already provided. Laravel even invented the service facades! But unlike Laravel, the service facades here are portable across different frameworks.

### Facades definition

[](#facades-definition)

The base classes for service facade definitions are provided by the [lagdo/facades](https://github.com/lagdo/facades) package.

A service facade based on this package can be use without any change with other frameworks, if a package for this framework is available, or a `PSR-11` container can be provided.

The following packages are also available:

- Symfony:
- CakePHP:
- Yii:

### Installation

[](#installation)

Install the package with `composer`.

```
composer require lagdo/laravel-facades
```

Register the `Lagdo\Laravel\Facades\FacadesBundle` bundle in the `config/bundles.php` file.

### Usage

[](#usage)

A service facade inherits from the `Lagdo\Facades\AbstractFacade` abstract class, and implements the `getServiceIdentifier()` method, which must return the id of the corresponding service in the service container.

```
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;
    }
}
```

The methods of the `App\Services\MyService` service can now be called using the `App\Facades\MyFacade` facade, like this.

```
class TheService
{
    public function theMethod()
    {
        MyFacade::myMethod();
    }
}
```

Instead of this.

```
class TheService
{
    /**
     * @var MyService
     */
    protected $myService;

    public function __construct(MyService $myService)
    {
        $this->myService = $myService;
    }

    public function theMethod()
    {
        $this->myService->myMethod();
    }
}
```

The `@extends AbstractFacade` phpdoc will prevent errors during code analysis with [PHPStan](https://phpstan.org/), and allow code completion on calls to service facades in editors.

### Getting the service instance

[](#getting-the-service-instance)

The `instance()` method of a service facade returns the instance of the linked service.

```
class TheService
{
    public function theMethod()
    {
        $service = MyFacade::instance();
        $service->myMethod();
    }
}
```

### The `Lagdo\Facades\ServiceInstance` trait

[](#the-lagdofacadesserviceinstance-trait)

By default, each call to a service facade method will also call the service container. The service instance can be saved in the facade after the first call to the service container, using the `Lagdo\Facades\ServiceInstance` trait. The next calls with return the service instance without calling the service container.

```
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 is called only once in this example code.

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

### Provided facades

[](#provided-facades)

Some service facades are included by default in this package.

#### Logger

[](#logger)

This facade requires that the `Psr\Log\LoggerInterface` id is defined and bound to the logger in the service container.

```
use Lagdo\Facades\Logger;

Logger::info($message, $vars);
```

Contribute
----------

[](#contribute)

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

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance46

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

413d 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 (3 commits)")

---

Tags

phpframeworklaravelfacadesservices

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[nunomaduro/laravel-desktop-notifier

Send notifications to your desktop from your Laravel commands. An JoliNotif wrapper for Laravel 5.

4781.7M8](/packages/nunomaduro-laravel-desktop-notifier)[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)[lagdo/symfony-facades

Call Symfony services using facades.

1868.7k](/packages/lagdo-symfony-facades)[dragon-code/support

Support package is a collection of helpers and tools for any project.

238.7M101](/packages/dragon-code-support)[kompo/kompo

Laravel &amp; Vue.js FullStack Components for Rapid Application Development

11812.4k21](/packages/kompo-kompo)[gdg-tangier/cloud-pubsub

Google Cloud pub-sub for laravel

5054.9k](/packages/gdg-tangier-cloud-pubsub)

PHPackages © 2026

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