WsApplication
in package
implements
Application
Tags
Table of Contents
Interfaces
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
- withMaxChannels() : self
- Cap the number of simultaneously live channel actors (SEC-002). Once the cap is reached, a new channel connection is refused with a 1013 close instead of spawning an unbounded number of actors/refs/mailboxes from an attacker churning unique channel keys. Dead channels (stopped on last close) free their slot. Default {@see ChannelActorRegistry::DEFAULT_MAX_CHANNELS}.
- withMessageSerializer() : self
- withoutDefaultExceptionHandler() : self
- withPoolSingletonSpawner() : self
- withRouteCache() : self
- ws() : self
- wsMiddleware() : self
- Append a PSR-15 middleware applied to EVERY WebSocket upgrade request, before per-route middleware, by the pre-upgrade HandshakeGate. Use this for AuthenticationMiddleware/AuthorizationMiddleware so WebSocket routes share the HTTP auth pipeline and reject unauthorized connections before the 101 switch.
Methods
actor()
public
actor(string $name, Props $props) : ActorRegistration
Parameters
- $name : string
- $props : Props
Attributes
- #[Override]
Return values
ActorRegistrationchannel()
public
channel(string $path, WebSocketChannelActor> $actorClass, string $key[, callable(): WebSocketChannelActor|null $factory = null ][, array<int, MiddlewareInterface|MiddlewareInterface>> $middleware = [] ]) : 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.
- $middleware : array<int, MiddlewareInterface|MiddlewareInterface>> = []
-
Per-route middleware run by the HandshakeGate before the upgrade.
Return values
selfclearRouteCache()
public
clearRouteCache() : void
Attributes
- #[Override]
compile()
public
compile() : CompiledWsApplication
Attributes
- #[Override]
Return values
CompiledWsApplicationcreate()
public
static create(ActorSystem $system) : self
Parameters
- $system : ActorSystem
Return values
selfdecorate()
public
static decorate(Application $inner, ActorSystem $system) : self
Parameters
- $inner : Application
- $system : ActorSystem
Return values
selfdelete()
public
delete(string $path, string|Closure $handler) : RouteBuilder
Parameters
- $path : string
- $handler : string|Closure
-
See self::get() for the closure contract.
Attributes
- #[Override]
Return values
RouteBuilderdiscover()
public
discover(string $directory) : self
Parameters
- $directory : string
Attributes
- #[Override]
Return values
selferrorMode()
public
errorMode(ErrorMode $mode) : self
Parameters
- $mode : ErrorMode
Attributes
- #[Override]
Return values
selfget()
public
get(string $path, string|Closure $handler) : RouteBuilder
Parameters
- $path : string
- $handler : string|Closure
-
Either a class FQN whose
__invokeis resolved by the registry, or a Closure whose params are resolved by registered ParamResolvers (#[FromPrincipal],#[FromBody],ServerRequestInterface, ...) and which returns either aResponseInterfaceor aFuture<ResponseInterface>.
Attributes
- #[Override]
Return values
RouteBuildergroup()
public
group(string $prefix, Closure $register) : RouteGroup
Parameters
- $prefix : string
- $register : Closure
Attributes
- #[Override]
Return values
RouteGroupinner()
public
inner() : Application
Return values
Applicationmiddleware()
public
middleware(string|MiddlewareInterface $middleware) : self
Parameters
- $middleware : string|MiddlewareInterface
Attributes
- #[Override]
Return values
selfonException()
public
onException(TException> $exceptionClass, callable(TException, ServerRequestInterface): ResponseInterface $mapper) : self
Parameters
- $exceptionClass : TException>
- $mapper : callable(TException, ServerRequestInterface): ResponseInterface
Tags
Attributes
- #[Override]
Return values
selfparamResolver()
public
paramResolver(ParamResolver $resolver[, bool $override = false ]) : self
Parameters
- $resolver : ParamResolver
- $override : bool = false
Attributes
- #[Override]
Return values
selfpatch()
public
patch(string $path, string|Closure $handler) : RouteBuilder
Parameters
- $path : string
- $handler : string|Closure
-
See self::get() for the closure contract.
Attributes
- #[Override]
Return values
RouteBuilderperRequestActor()
public
perRequestActor(string $name, Props $props) : ActorRegistration
Parameters
- $name : string
- $props : Props
Attributes
- #[Override]
Return values
ActorRegistrationpost()
public
post(string $path, string|Closure $handler) : RouteBuilder
Parameters
- $path : string
- $handler : string|Closure
-
See self::get() for the closure contract.
Attributes
- #[Override]
Return values
RouteBuilderput()
public
put(string $path, string|Closure $handler) : RouteBuilder
Parameters
- $path : string
- $handler : string|Closure
-
See self::get() for the closure contract.
Attributes
- #[Override]
Return values
RouteBuilderregisteredRoutes()
Snapshot of every route registered so far. Intended for index pages, smoke tests, and admin/debugging tooling.
public
registeredRoutes() : array<int, RouteSummary>
Attributes
- #[Override]
Return values
array<int, RouteSummary>requiresPoolSingleton()
public
requiresPoolSingleton() : bool
Attributes
- #[Override]
Return values
boolwithContainer()
public
withContainer(ContainerInterface $container) : self
Parameters
- $container : ContainerInterface
Return values
selfwithLogger()
public
withLogger(LoggerInterface $logger) : self
Parameters
- $logger : LoggerInterface
Return values
selfwithMaxChannels()
Cap the number of simultaneously live channel actors (SEC-002). Once the cap is reached, a new channel connection is refused with a 1013 close instead of spawning an unbounded number of actors/refs/mailboxes from an attacker churning unique channel keys. Dead channels (stopped on last close) free their slot. Default {@see ChannelActorRegistry::DEFAULT_MAX_CHANNELS}.
public
withMaxChannels(int $maxChannels) : self
Parameters
- $maxChannels : int
Return values
selfwithMessageSerializer()
public
withMessageSerializer(MessageSerializer $serializer) : self
Parameters
- $serializer : MessageSerializer
Attributes
- #[Override]
Return values
selfwithoutDefaultExceptionHandler()
public
withoutDefaultExceptionHandler() : self
Attributes
- #[Override]
Return values
selfwithPoolSingletonSpawner()
public
withPoolSingletonSpawner(PoolSingletonSpawner $spawner) : self
Parameters
- $spawner : PoolSingletonSpawner
Attributes
- #[Override]
Return values
selfwithRouteCache()
public
withRouteCache(CacheInterface $cache[, string|null $key = null ]) : self
Parameters
- $cache : CacheInterface
- $key : string|null = null
Attributes
- #[Override]
Return values
selfws()
public
ws(string $path, WebSocketHandler> $handlerClass[, array<int, MiddlewareInterface|MiddlewareInterface>> $middleware = [] ]) : self
Parameters
- $path : string
- $handlerClass : WebSocketHandler>
- $middleware : array<int, MiddlewareInterface|MiddlewareInterface>> = []
-
Per-route middleware run by the HandshakeGate before the upgrade.
Return values
selfwsMiddleware()
Append a PSR-15 middleware applied to EVERY WebSocket upgrade request, before per-route middleware, by the pre-upgrade HandshakeGate. Use this for AuthenticationMiddleware/AuthorizationMiddleware so WebSocket routes share the HTTP auth pipeline and reject unauthorized connections before the 101 switch.
public
wsMiddleware(MiddlewareInterface|MiddlewareInterface> $middleware) : self
Parameters
- $middleware : MiddlewareInterface|MiddlewareInterface>