phpnomad/facade

Maintainers

Package info

github.com/phpnomad/facade

Homepage

pkg:composer/phpnomad/facade

Statistics

Installs: 3 984

Dependents: 5

Suggesters: 0

Stars: 0

Open Issues: 3

1.1.0 2026-03-31 15:22 UTC

README

Latest Version Total Downloads PHP Version License

phpnomad/facade provides the base classes and interfaces for building static-bound service facades in PHPNomad. The abstract Facade class resolves its target through the DI container on demand, and the HasFacades interface lets an initializer register its facades with the framework during bootstrap. The pattern is how you end up calling Cache::get($key) or Logger::error($message) from anywhere in your code without wiring up the container at each call site.

Installation

composer require phpnomad/facade

Most applications pull this in as a transitive dependency of phpnomad/core, which ships concrete facades for cache, events, logging, templates, and URL and path resolution.

Overview

  • PHPNomad\Facade\Abstracts\Facade is a generic, container-aware base class. A concrete subclass implements abstractInstance() to name the bound interface, and the base pulls the resolved implementation from the DI container when a facade method is called.
  • PHPNomad\Facade\Interfaces\HasFacades is the contract initializers implement to advertise their facades. Return an array of facade instances from getFacades() and the framework hands each one a container reference during the loader phase.
  • Resolution is lazy. The container is queried when a facade method fires, not when the facade is registered, so services with expensive dependencies stay cheap until something actually calls them.
  • When container resolution throws a DiException, the base attempts to log a critical error through LoggerStrategy with the failing abstraction and the container reference before rethrowing, so you get a breadcrumb instead of a bare stack trace.

For working examples of concrete facades built on this base, see the Facades/ directory in phpnomad/core (Cache, Event, Logger, Template, UrlResolver, PathResolver, InstanceProvider).

Documentation

Full framework documentation lives at phpnomad.com.

License

MIT. See LICENSE.txt.