Nexus API Reference

WsApplication
in package
implements Application

FinalYes
Tags
psalm-api

Decorates any Application (typically HttpApplication) and adds the WebSocket DSL. Compiles to CompiledWsApplication.

Table of Contents

Interfaces

Application

Methods

actor()  : ActorRegistration
channel()  : self
clearRouteCache()  : void
compile()  : CompiledWsApplication
create()  : self
decorate()  : self
delete()  : RouteBuilder
discover()  : self
errorMode()  : self
get()  : RouteBuilder
group()  : RouteGroup
inner()  : Application
middleware()  : self
onException()  : self
paramResolver()  : self
patch()  : RouteBuilder
perRequestActor()  : ActorRegistration
post()  : RouteBuilder
put()  : RouteBuilder
registeredRoutes()  : array<int, RouteSummary>
Snapshot of every route registered so far. Intended for index pages, smoke tests, and admin/debugging tooling.
requiresPoolSingleton()  : bool
withContainer()  : self
withLogger()  : self
withMessageSerializer()  : self
withoutDefaultExceptionHandler()  : self
withPoolSingletonSpawner()  : self
withRouteCache()  : self
ws()  : self

Methods

channel()

public channel(string $path, WebSocketChannelActor> $actorClass, string $key[, callable(): WebSocketChannelActor|null $factory = null ]) : self
Parameters
$path : string
$actorClass : WebSocketChannelActor>
$key : string
$factory : callable(): WebSocketChannelActor|null = null

Optional constructor. When null the dispatcher zero-arg instantiates the class. Pass a factory when the channel actor needs dependencies (e.g. an EntityRefFactory or a repository) that DI would otherwise supply on an HTTP handler.

Return values
self

delete()

public delete(string $path, string|Closure $handler) : RouteBuilder
Parameters
$path : string
$handler : string|Closure

See self::get() for the closure contract.

Return values
RouteBuilder

discover()

public discover(string $directory) : self
Parameters
$directory : string
Return values
self

get()

public get(string $path, string|Closure $handler) : RouteBuilder
Parameters
$path : string
$handler : string|Closure

Either a class FQN whose __invoke is resolved by the registry, or a Closure whose params are resolved by registered ParamResolvers (#[FromPrincipal], #[FromBody], ServerRequestInterface, ...) and which returns either a ResponseInterface or a Future<ResponseInterface>.

Return values
RouteBuilder

middleware()

public middleware(string|MiddlewareInterface $middleware) : self
Parameters
$middleware : string|MiddlewareInterface
Return values
self

onException()

public onException(TException> $exceptionClass, callable(TException, ServerRequestInterface): ResponseInterface $mapper) : self
Parameters
$exceptionClass : TException>
$mapper : callable(TException, ServerRequestInterface): ResponseInterface
Tags
template

TException of \Throwable

Return values
self

patch()

public patch(string $path, string|Closure $handler) : RouteBuilder
Parameters
$path : string
$handler : string|Closure

See self::get() for the closure contract.

Return values
RouteBuilder

post()

public post(string $path, string|Closure $handler) : RouteBuilder
Parameters
$path : string
$handler : string|Closure

See self::get() for the closure contract.

Return values
RouteBuilder

put()

public put(string $path, string|Closure $handler) : RouteBuilder
Parameters
$path : string
$handler : string|Closure

See self::get() for the closure contract.

Return values
RouteBuilder

registeredRoutes()

Snapshot of every route registered so far. Intended for index pages, smoke tests, and admin/debugging tooling.

public registeredRoutes() : array<int, RouteSummary>
Return values
array<int, RouteSummary>

requiresPoolSingleton()

public requiresPoolSingleton() : bool
Return values
bool

withContainer()

public withContainer(ContainerInterface $container) : self
Parameters
$container : ContainerInterface
Return values
self

withLogger()

public withLogger(LoggerInterface $logger) : self
Parameters
$logger : LoggerInterface
Return values
self

withoutDefaultExceptionHandler()

public withoutDefaultExceptionHandler() : self
Return values
self

withRouteCache()

public withRouteCache(CacheInterface $cache[, string|null $key = null ]) : self
Parameters
$cache : CacheInterface
$key : string|null = null
Return values
self

ws()

public ws(string $path, WebSocketHandler> $handlerClass) : self
Parameters
$path : string
$handlerClass : WebSocketHandler>
Return values
self

        
On this page

Search results