GithubHelp home page GithubHelp logo

facade's Introduction

This package has been superceded by BapCat/Facade.

Build Status Coverage Status License

Phi Facades

Facades are a way to make Phi bindings feel more natural.

Installation

Composer

Composer is the recommended method of installation for Facade.

$ composer require lordmonoxide/facade

GitHub

Facade may be downloaded from GitHub.

Features

Pseudo-Static Access To Phi Singletons

A common use-case for Phi Facades is logging:

namespace Vendor\Package\Logging;

class Logger {
  public function warning($text) {
    // ...
  }
}
$logger = new Vendor\Package\Logging\Logger;

$phi = LordMonoxide\Phi\Phi::instance();
$phi->bind('core.log', $logger);
use LordMonoxide\Facade\Facade;

class Log extends Facade {
  protected static $_binding = 'core.log';
}

Once the facade is set up, the Vendor\Package\Logging singleton can be accessed like this:

Log::warning('Something bad happened!');

Phi Facades can even be used to create a facade for Phi:

$phi = LordMonoxide\Phi\Phi::instance();
$phi->bind('phi', $phi);
use LordMonoxide\Facade\Facade;

class Phi extends Facade {
  protected static $_binding = 'phi';
}

This will allow Phi to be accessed as such:

Phi::bind('Bar', 'Foo');
$foo = Phi::make('Bar');

Phi Custom Resolvers

If you are using Phi 1.2.0 or greater, Phi facades will work seamlessly with custom resolvers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.