Download the PHP package laikait/laika-relay without Composer

On this page you can find all versions of the php package laikait/laika-relay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laika-relay

Laika Framework Relay (Service Container & Static Proxy)

Relay is the service container and static proxy system built for the Laika Framework. It gives you a lightweight dependency injection container (RelayRegistry), a clean static proxy base (Relay), and a two-phase provider system (RelayProvider + ProviderRegistry) that lets third-party packages register their own services into the framework.

Part of laikait/laika-core · Requires PHP 8.1+


Table of Contents


How It Works

There are three independent pieces:

Class Role
RelayRegistry The container. Holds bindings, resolves and caches instances.
Relay Abstract base. Forwards static calls to the resolved instance.
RelayProvider Integration point. Packages extend this to register services.
ProviderRegistry Manages provider lifecycle — calls register() then boot().

File Structure & Default Services

services/ [Laika\Service\*] is a convention, not a requirement. Relay classes can live anywhere.


RelayRegistry

The container. All services are registered here before the application starts handling requests.


instance()

Register an already-constructed object directly.

The registry stores exactly the object you give it — it never calls new. The object is available immediately on make().

Use when the object already exists before the registry is set up, or when construction has side effects that must be controlled manually.


singleton()

Register a singleton binding — built once on the first make() call, then cached and reused for the lifetime of the request.

Use for stateful services shared across the entire request: session, auth, config, mailer, cache.


bind()

Register a transient binding — a brand-new instance is created on every make() call. Nothing is ever cached.

Use for stateless, disposable objects where shared state would be a bug: validators, form request objects, DTOs, value objects.


make()

Resolve a binding by key and return the object.

Resolution order:


has()

Check whether a key has any binding registered.


forgetInstance()

Clear a cached singleton instance, forcing re-resolution on the next make().


Lifetime Comparison

Method Who builds it How many instances When built Cached
instance() You 1 (yours) Before registration Yes — immediately
singleton() Registry 1 On first make() Yes — after first use
bind() Registry N (one per call) On every make() Never

Prefer singleton() over instance() for most services. singleton() is lazy — if nothing ever calls make('x'), the object is never constructed. instance() is eager — the object exists the moment you register it, whether anything uses it or not.


Auto-Wiring

When a class string is registered (not a Closure), the registry uses PHP reflection to resolve constructor parameters automatically.

Per-parameter resolution order:

Mixed — auto-wire objects, supply primitives:


RelayProvider

The integration point for packages. Extend RelayProvider and implement register(). Optionally override boot().


register()

Only call bind(), singleton(), or instance() here. Do not call make().

When register() runs, other providers may not have registered their services yet. Calling make() at this stage risks a RelayException if the dependency is not yet bound.


boot()

Called after all providers have run register(). Safe to call make() freely.


register() vs boot()

register() boot()
Purpose Promise a service exists Use services that others promised
When called Before other providers boot After ALL providers have registered
Call make()? ⚠️ Risky — others may not be ready ✅ Safe — everything is registered
Typical use singleton, bind, instance Config setup, routes, middleware, events

One-line rule: register() = bind things. boot() = use things.


ProviderRegistry

Manages the full provider lifecycle. Register providers in any order — the two-phase approach guarantees correctness.

Duplicate registrations are silently ignored — registering the same provider class twice is safe.

has() — check if a provider is registered:


Bootstrap

Complete application bootstrap sequence:

config/app.php:


Third-Party Integration

This is how an external package integrates with Laika.

1. Create a RelayProvider

2. Ship a Relay class (optional but recommended)

Full flow


Relay — The Static Proxy

Creating a Relay Class

Extend Relay, implement getRelayAccessor(), and document every proxied method with @method static tags.

@method tag rules:


Using a Relay

Import the Relay class, not the underlying service class.

You do not need a Relay class to access a service. The registry is always available:


Method Chaining

Chaining works automatically. The first static call goes through __callStatic and returns whatever the underlying method returns. If that's $this, subsequent calls are normal instance calls.

Chaining ends when a method returns a non-object (string, int, array). Do not chain after terminal methods like format(), getTimestamp(), or toArray().


Switching Instances at Runtime

Use swap() to replace the resolved instance for a specific Relay — for example, switching auth guard in middleware.

Or re-register via the registry for a cleaner approach:


Testing

Inject a mock for one test

Replace the entire registry for full isolation

swapRegistry() is intentionally separate from setRegistry() so that accidental double-calls in production code throw a RelayException, while tests can swap freely.


Exceptions

All errors throw Laika\Relay\Exceptions\RelayException.

Situation Message
setRegistry() called more than once RelayRegistry has already been set.
getRegistry() before setRegistry() RelayRegistry has not been set.
No binding found for key No binding registered for [key].
Class not found during build Class [ClassName] not found.
Unresolvable constructor parameter Cannot resolve parameter [$name] for [ClassName].
Method not found on resolved instance Method [method] does not exist on [ClassName].
RelayProvider class not found RelayProvider [ClassName] class not found.
Provider does not extend RelayProvider [ClassName] must extend Laika\Relay\RelayProvider.

License

MIT — see LICENSE for details.

Author: Showket Ahmed Email: [email protected] Package: laikait/laika-relay GitHub: laikait/laika-relay


All versions of laika-relay with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laikait/laika-relay contains the following files

Loading the files please wait ...