Module
WebSocket module definition backed by Phalcon's CLI-style dispatcher.
WebSocket tasks are routed like CLI tasks but run under the WebSocket/Swoole runtime. The module registers task/model namespaces and configures dispatcher and router defaults for the long-running listen action.
- Full name:
\PhalconKit\Ws\Module - This class implements:
ModuleDefinitionInterface
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
NAME_WS | public | string | 'ws' |
Properties
name
public string $name
config
public ?\PhalconKit\Bootstrap\Config $config
dispatcher
public ?\PhalconKit\Ws\Dispatcher $dispatcher
loader
public ?\Phalcon\Autoload\Loader $loader
router
public ?\PhalconKit\Ws\Router $router
Methods
registerAutoloaders
Register task/model namespaces for the WebSocket module.
public registerAutoloaders(?\Phalcon\Di\DiInterface $container = null): void
When a loader service is registered, it must be a Phalcon autoloader. Otherwise the module creates a local loader for task and model namespaces.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$container | ?\Phalcon\Di\DiInterface |
registerServices
Resolve and configure dispatcher/router services for WebSocket tasks.
public registerServices(\Phalcon\Di\DiInterface $container): void
Registered replacements for dispatcher and router are resolved through the shared service resolver so invalid module wiring fails before the module mutates service state.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$container | \Phalcon\Di\DiInterface |
getNamespaces
Return namespace-to-directory mappings registered by the module loader.
public getNamespaces(): array<string,string>
getServices
Resolve module-owned services from DI or create local defaults.
public getServices(\Phalcon\Di\DiInterface|null $container = null): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$container | \Phalcon\Di\DiInterface|null | Optional DI container used by Phalcon |
| module registration. |
setServices
Store resolved module services back into the active DI container.
public setServices(\Phalcon\Di\DiInterface $container): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$container | \Phalcon\Di\DiInterface |
getDefaultNamespace
Return the default task namespace for dispatcher routing.
public getDefaultNamespace(): string
getDirname
Return the filesystem directory that contains this module class.
public getDirname(): string
getNamespace
Return the PHP namespace for this module class.
public getNamespace(): string