Lumberjack
WebsiteRareloopTimber DocumentationTwig Documentation
v4
v4
  • Introduction
  • What's New
  • Upgrade Guide
  • Getting Started
    • Installation
    • Configuration
  • The Basics
    • Lifecycle
    • Routing
    • WordPress Controllers
    • Post Types
    • Query Builder
    • View Models
    • HTTP Requests
    • HTTP Responses
    • Middleware
    • Sessions
    • Helpers
    • Collections
  • Container
    • Using the Container
    • Service Providers
    • Facades
  • Misc
    • Contributing
    • Notable Mentions
    • Code of Conduct
    • View on GitHub
    • View Docs on GitHub
    • Submit an issue
Powered by GitBook
On this page
  • Creating a Facade
  • Available Facades
  • Example usage
  1. Container

Facades

PreviousService ProvidersNextContributing

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

Available Facades

Lumberjack comes with a handful of useful Facades. Below you can see which class the Facade references and what it is bound to the container under.

Facade
Class Reference
Container binding

Config

Rareloop\Lumberjack\Config

config

Log

Monolog\Logger

logger

Router

Rareloop\Lumberjack\Http\Route

router

Session

Rareloop\Lumberjack\Session\SessionManager

session

Example usage

All of Lumberjack's Facades live under the Rareloop\Lumberjack\Facades namespace.

Config

The Config facade allows you to get and set values from your config.

use Rareloop\Lumberjack\Facades\Config;

Config::set('app.debug', false);

$value = Config::get('app.debug');

Log

use Rareloop\Lumberjack\Facades\Log;

$value = Log::warning('Oops! Something went wrong');

Router

The Router facade allows you to create custom routes or get the URLs for your routes.

use Rareloop\Lumberjack\Facades\Router;

Router::get('posts/all', function () {})->name('posts.index');

$url = Router::url('posts.index');

Session

The Session facade allows you to retrieve and store data in the current session.

use Rareloop\Lumberjack\Facades\Session;

Session::put('name', 'Chris');

$name = Session::get('name');

Config is also available as a

The Log facade allows you to use the Logger .

See for more information.

Session is also available as a

Blast Facades
Helper
PSR-3
Monolog
Creating Routes
Helper