Skip to content

Bootstrap

Phalcon Kit's Bootstrap for the MVC Application & CLI Console mode


  • Full name: \PhalconKit\Bootstrap

Constants

Constant Visibility Type Value
MODE_CLI public 'cli'
MODE_WS public 'ws'
MODE_MVC public 'mvc'

Properties

di

public \Phalcon\Di\DiInterface $di

mode

public string $mode

args

public ?array $args

config

public ?\PhalconKit\Config\ConfigInterface $config

router

public ?\PhalconKit\Router\RouterInterface $router

response

public ?\Phalcon\Http\ResponseInterface $response

cliDoc

public string $cliDoc

Methods

__construct

public __construct(?string $mode = null): mixed

Parameters:

Parameter Type Description
$mode ?string

Throws:


initialize

Initialisation

public initialize(): void

setDI

Set the default DI

public setDI(?\Phalcon\Di\DiInterface $di = null): void

Parameters:

Parameter Type Description
$di ?\Phalcon\Di\DiInterface

setMode

public setMode(?string $mode = null): void

Parameters:

Parameter Type Description
$mode ?string

getMode

public getMode(): string

getDI

Get the default DI

public getDI(): \Phalcon\Di\DiInterface

setConfig

Set the Config

public setConfig(\PhalconKit\Config\ConfigInterface $config): void

Parameters:

Parameter Type Description
$config \PhalconKit\Config\ConfigInterface

getConfig

Get the Config

public getConfig(): \PhalconKit\Config\ConfigInterface

setRouter

Set the MVC or CLI Router

public setRouter(\PhalconKit\Router\RouterInterface $router): void

Parameters:

Parameter Type Description
$router \PhalconKit\Router\RouterInterface

getRouter

Get the MVC or CLI Router

public getRouter(): ?\PhalconKit\Router\RouterInterface

registerConfig

Register Config

public registerConfig(): void

registerServices

Register Service Providers

public registerServices(?array $providers = null): void

Parameters:

Parameter Type Description
$providers ?array

Throws:


registerRouter

Register Router

public registerRouter(): void

bootServices

Boot Service Providers

public bootServices(): void

registerModules

Register modules

public registerModules(?\Phalcon\Application\AbstractApplication $application = null, ?array $modules = null, ?string $defaultModule = null): void

Parameters:

Parameter Type Description
$application ?\Phalcon\Application\AbstractApplication
$modules ?array
$defaultModule ?string

Throws:


run

Handle cli or mvc application

public run(): ?string

Throws:


handleConsole

Handle Console (For CLI only)

public handleConsole(\PhalconKit\Cli\Console $console): ?string

Parameters:

Parameter Type Description
$console \PhalconKit\Cli\Console

handleWebSocket

Handle Swoole (For WebSocket only)

public handleWebSocket(\PhalconKit\Ws\WebSocket $webSocket): ?string

Parameters:

Parameter Type Description
$webSocket \PhalconKit\Ws\WebSocket

handleApplication

Handle Application (For MVC only)

public handleApplication(\PhalconKit\Mvc\Application $application): ?string

Parameters:

Parameter Type Description
$application \PhalconKit\Mvc\Application

Throws:


getArgs

Get & format args from the $this->args property

public getArgs(): array

isCli

Return true if the bootstrap mode is set to 'cli'

public isCli(): bool

isWs

Return true if the bootstrap mode is set to 'ws'

public isWs(): bool

isMvc

Return true if the bootstrap mode is set to 'mvc'

public isMvc(): bool

Inherited methods

setEventsManager

Set the events manager

public setEventsManager(\Phalcon\Events\ManagerInterface $manager): void

Parameters:

Parameter Type Description
$manager \Phalcon\Events\ManagerInterface

getEventsManager

Get the events manager.

public getEventsManager(): ?\Phalcon\Events\ManagerInterface

getEventsPrefix

Get the event component prefix

public static getEventsPrefix(): string|null
  • This method is static. Return Value:

The event component prefix, or null if not set


setEventsPrefix

Sets the events prefix.

public static setEventsPrefix(string|null $eventsPrefix): void
  • This method is static. Parameters:
Parameter Type Description
$eventsPrefix string|null The prefix to be used for events. Pass null to remove the prefix.

fire

Fire an event.

public fire(string $task, mixed|null $data = null, bool $cancelable = false): mixed

Parameters:

Parameter Type Description
$task string The task to execute.
$data mixed|null The optional data to pass to the event.
$cancelable bool Whether the event is cancelable or not. Defaults to false.