Lumberjack
WebsiteRareloopTimber DocumentationTwig Documentation
v3
v3
  • Documentation
  • Getting Started
    • Installation
    • Quick Start
    • Configuration
  • The Basics
    • Lifecycle
    • Post Types
    • WordPress Controllers
    • Routing
    • HTTP Responses
  • Container
    • Using the Container
    • Service Providers
    • Facades
  • Misc
    • Changelog
    • Contributing
    • Notable Mentions
    • Code of Conduct
    • View on GitHub
    • Submit an issue
Powered by GitBook
On this page
  1. Container

Facades

PreviousService ProvidersNextChangelog

Last updated 2 years ago

Lumberjack uses the library.

Creating a Facade

Facades provide a simple static API to an object that has been registered into the container. For example to setup a facade you would first use a Service Provider to register an instance of your class into the container:

namespace Rareloop\Lumberjack\Providers;

use Monolog\Logger;
use Rareloop\Lumberjack\Application;

class LogServiceProvider extends ServiceProvider
{
    public function register()
    {
        // Create object instance and bind into container
        $this->app->bind('logger', new Logger('app'));
    }
}

Then create a Facade subclass and tell it which key to use to retrieve your class instance:

namespace Rareloop\Lumberjack\Facades;

use Blast\Facades\AbstractFacade;

class Log extends AbstractFacade
{
    protected static function accessor()
    {
        return 'logger';
    }
}
Blast Facades