Skip to content

Bootstrap

Zemit Core's Bootstrap for the MVC Application & CLI Console mode

  • Full name: \Zemit\Bootstrap

Constants

Constant Visibility Type Value
MODE_CLI public 'cli'
MODE_MVC public 'mvc'
MODE_DEFAULT public self::MODE_MVC
MODE_CONSOLE public self::MODE_CLI

Properties

mode

public string $mode

args

public ?array $args

di

public \Phalcon\Di\DiInterface $di

config

public ?\Zemit\Config\ConfigInterface $config

router

public ?\Zemit\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(\Zemit\Config\ConfigInterface $config): void

Parameters:

Parameter Type Description
$config \Zemit\Config\ConfigInterface

getConfig

Get the Config

public getConfig(): \Zemit\Config\ConfigInterface

setRouter

Set the MVC or CLI Router

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

Parameters:

Parameter Type Description
$router \Zemit\Router\RouterInterface

getRouter

Get the MVC or CLI Router

public getRouter(): ?\Zemit\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

run

Handle cli or mvc application

public run(): ?string

Throws:


handleConsole

Handle Console (For CLI only)

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

Parameters:

Parameter Type Description
$console \Zemit\Cli\Console

handleApplication

Handle Application

public handleApplication(\Zemit\Mvc\Application $application): string

Parameters:

Parameter Type Description
$application \Zemit\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

isMvc

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

public isMvc(): bool

isConsole

Alias for the ->isCli() method

public isConsole(): bool
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.

isDefault

Alias for the ->isMvc() method

public isDefault(): bool
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.

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**

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**
$cancelable bool Whether the event is cancelable or not. Defaults to false.