0

I want to create a facade for a singleton that I'v defined in ServiceProvider:

$this->app->singleton('\ActivityLogger\ActivityLoggerInterface', '\ActivityLogger\ActivityLogger');

How can I have something like this in my code:

Logger::log($data)

thanks

jedrzej.kurylo
  • 39,591
  • 9
  • 98
  • 107

1 Answers1

1

Since version 5.5 Laravel makes it possible to use real-time facades: https://laravel.com/docs/5.5/facades#real-time-facades.

In order to make it work, you need to prepend the use statement that imports your class with Facades\:

<?php
use Facades\ActivityLogger\ActivityLogger as Logger;

//...and then in your code
Logger::debug($data);
jedrzej.kurylo
  • 39,591
  • 9
  • 98
  • 107