Download the PHP package jaz303/hotwire without Composer
On this page you can find all versions of the php package jaz303/hotwire. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package hotwire
Hotwire
Installation
Usage
Basic Example
Lazy Dependencies
Factory Dependencies
Documentation
$C = new Hotwire\Container()
Create a new container instance.
$C->register(string $key, callable $factory)
Register a factory dependency. $factory
will be called each time an instance of $key
is requested from the container, and its return value returned.
$C->registerSingleton(string $key, mixed $factoryOrInstance)
Register a singleton dependency. If $factoryOrInstance
is a callable it is used as a factory function that is called the first time $key
is requested from the container; otherwise $factoryOrInstance
is the dependency itself.
$C->has($key)
Returns true
if a registration exists for the given $key
, false
otherwise.
$C->get($key)
Request an instance of $key
from the container.
Throws RegistrationNotFoundException
if no registration for $key
exists.
$C->lazy(string $key)
Request a lazy instance of $key
from the container. Returns a callable that returns an instance of the associated dependency. Successive calls will return the same instance.
Use lazy()
for expensive dependencies that will not always be used by the dependent object.
$C->factory(string $key)
Request a factory for $key
. Returns a callable that returns a new instance of the associated dependency for each call.
Attempting to create a factory()
dependency for a singleton registration is a semantic error and will throw an exception.
Use factory()
when an object needs to create multiple instances of a dependency, without exposing the container itself.
$C->__get(string $key)
Equivalent to $C->get($key)
.