Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Laravel: how to find concrete implementation of a Facade?

This is the link to source code of Laravel (v8 but it’s not important) about Redis Facade

https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Facades/Facade.php#L164

I would like to find the ‘concrete’ Redis class served by the facade itself.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I do? Where does Laravel framework bind this facade to a "real" class?

>Solution :

Concrete implementation of a Facade in Laravel is served from the service container.

For Redis you can find in vendor/laravel/framework/src/Illuminate/Redis/RedisServiceProvider.php

In Laravel 9.3 you can see something like this

public function register()
{
    $this->app->singleton('redis', function ($app) {
        $config = $app->make('config')->get('database.redis', []);

        return new RedisManager($app, Arr::pull($config, 'client', 'phpredis'), $config);
    });

    $this->app->bind('redis.connection', function ($app) {
        return $app['redis']->connection();
    });
}

RedisManager is the concrete implementation of the Redis. Whenever you call methods on the Redis, you’re calling methods on the RedisManager only.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading