Raydium Framework

AppBoot
in package
implements AppInterface

Interfaces, Classes, Traits and Enums

AppInterface

Table of Contents

_REQUIRED_CONSTANT  = true
$builder  : ConstantBuilder
$configs  : Configs
$isMultitenant  : bool|null
$logger  : LoggerInterface
$app  : App
$appDirPath  : string
$environment  : string|null
$httpFactory  : HostManager
$ipResolver  : ClientIpResolver
$request  : ServerRequestInterface
$tenantResolver  : Tenant
__construct()  : mixed
AppFactory constructor.
init()  : App
Creates and configures the application instance.
isTestMode()  : bool
Check if the application is running in test mode.
run()  : void
Runs the created application.
handleOfflineMode()  : void
Handles offline mode by sending appropriate headers and displaying the offline page.
inOfflineMode()  : bool
Checks if the application is in offline mode and terminates execution if enabled.
isMultitenantApp()  : bool
Determines if the application is configured to operate in multi-tenant mode.
copyConfigSampleFile()  : void
Copies <configs>/<file>.php ➜ <configs>/<file>.sample.php – Does nothing if the user‑specific file already exists.
createPrivateDir()  : void
Create private directory if it doesn't exist.
createRequest()  : ServerRequestInterface
Create server request instance.
defineEarlyConstants()  : void
defineInitialConstants()  : void
Define initial constants required by the application.
defineMandatoryConstants()  : null|ConstantBuilder
Define mandatory application constants.
getEnvironmentFiles()  : array<string|int, mixed>
Get environment files for the application.
getTenant()  : mixed
Get tenant information from the request.
loadDotEnv()  : void
Load dot environment files.
loadEarlyConfiguration()  : void
loadZeroConfig()  : void
Load zero configuration file if it exists.
setAppDirectoryPath()  : string
Sets the application directory path by locating the Composer autoloader.
setEnvironment()  : void
Set the environment type for the application.
setErrorHandler()  : void
Set up error handler for the application.
setupContainer()  : Bindings
Set up the dependency injection container.
setupEnvironment()  : void
Set up the application environment.

Constants

_REQUIRED_CONSTANT

private bool _REQUIRED_CONSTANT = true

Properties

$builder

protected ConstantBuilder $builder

$isMultitenant

protected bool|null $isMultitenant

$logger

protected LoggerInterface $logger

$appDirPath

private string $appDirPath

$environment

private string|null $environment

$request

private ServerRequestInterface $request

Methods

__construct()

AppFactory constructor.

public __construct(string $appDirPath[, null|string $environment = null ][, null|ServerRequestInterface $request = null ][, null|ClientIpResolver $ipResolver = null ][, null|Tenant $tenantResolver = null ][, null|HostManager $httpFactory = null ][, null|ConstantBuilder $builder = null ]) : mixed
Parameters
$appDirPath : string

The directory path for the application

$environment : null|string = null

The environment setting

$request : null|ServerRequestInterface = null

Optional server request

$ipResolver : null|ClientIpResolver = null

Optional IP resolver

$tenantResolver : null|Tenant = null

Optional tenant resolver

$httpFactory : null|HostManager = null

Optional HTTP factory

$builder : null|ConstantBuilder = null

Optional ConstantBuilder

Return values
mixed —

init()

Creates and configures the application instance.

public init() : App
Return values
App —

An initialized App instance.

isTestMode()

Check if the application is running in test mode.

public static isTestMode() : bool
Return values
bool —

True if running in test mode, false otherwise

run()

Runs the created application.

public run() : void
Tags
throws
RuntimeException

if the app hasn't been created yet

Return values
void —

handleOfflineMode()

Handles offline mode by sending appropriate headers and displaying the offline page.

protected handleOfflineMode(string $appDirPath[, int $retryAfter = 1800 ]) : void

This method is called when the application is in offline mode. It:

  • Sends a 503 Service Unavailable HTTP status code
  • Sets a Retry-After header suggesting when to retry
  • Outputs a clean, user-friendly offline page
  • Terminates the application execution
Parameters
$appDirPath : string
$retryAfter : int = 1800

Number of seconds after which the client should retry (default: 1800 = 30 minutes)

Return values
void —

This method terminates execution and does not return

inOfflineMode()

Checks if the application is in offline mode and terminates execution if enabled.

protected inOfflineMode() : bool

This function checks the OFFLINE_MODE constant to determine if the application should be taken offline. Unlike maintenance mode which checks for files in various locations, offline mode is controlled via a single constant that must be set early in the application bootstrap process.

When offline mode is active, it sends a 503 Service Unavailable status code and displays a clean offline page to all visitors.

Return values
bool —

Returns true if offline mode is enabled, false otherwise

isMultitenantApp()

Determines if the application is configured to operate in multi-tenant mode.

protected static isMultitenantApp(mixed $composerConfig) : bool
Parameters
$composerConfig : mixed
Return values
bool —

Returns true if the application is in multi-tenant mode, otherwise false.

copyConfigSampleFile()

Copies <configs>/<file>.php ➜ <configs>/<file>.sample.php – Does nothing if the user‑specific file already exists.

private copyConfigSampleFile(string $file, Container $c) : void
Parameters
$file : string

Basename without extension (e.g. 'constants', 'app')

$c : Container

PSR‑11 container with filesystem + configs

Return values
void —

createPrivateDir()

Create private directory if it doesn't exist.

private createPrivateDir(Container $psrContainer) : void
Parameters
$psrContainer : Container

PSR-11 container

Return values
void —

createRequest()

Create server request instance.

private createRequest([null|ServerRequestInterface $request = null ]) : ServerRequestInterface
Parameters
$request : null|ServerRequestInterface = null

Optional server request

Return values
ServerRequestInterface —

Server request instance

defineEarlyConstants()

private defineEarlyConstants(string $appDirPath) : void
Parameters
$appDirPath : string
Return values
void —

defineInitialConstants()

Define initial constants required by the application.

private defineInitialConstants(null|TenantInfo $tenantInfo) : void
Parameters
$tenantInfo : null|TenantInfo

Tenant information

Return values
void —

defineMandatoryConstants()

Define mandatory application constants.

private defineMandatoryConstants(string $httpHost, string $peerIp) : null|ConstantBuilder
Parameters
$httpHost : string

HTTP host

$peerIp : string

Peer IP address

Return values
null|ConstantBuilder —

Constant builder instance or null if in test mode

getEnvironmentFiles()

Get environment files for the application.

private getEnvironmentFiles(EnvType $envType) : array<string|int, mixed>
Parameters
$envType : EnvType

Environment type instance

Return values
array<string|int, mixed> —

List of environment files

getTenant()

Get tenant information from the request.

private getTenant(ServerRequestInterface $request) : mixed
Parameters
$request : ServerRequestInterface

Server request

Return values
mixed —

Tenant information

loadDotEnv()

Load dot environment files.

private loadDotEnv(array<string|int, mixed> $envFiles, EnvType $envType) : void
Parameters
$envFiles : array<string|int, mixed>

Environment files

$envType : EnvType

Environment type instance

Return values
void —

loadEarlyConfiguration()

private loadEarlyConfiguration() : void
Return values
void —

loadZeroConfig()

Load zero configuration file if it exists.

private loadZeroConfig() : void
Return values
void —

setAppDirectoryPath()

Sets the application directory path by locating the Composer autoloader.

private static setAppDirectoryPath(string $appDirPath) : string
Parameters
$appDirPath : string

The initial application directory path

Tags
throws
InvalidArgumentException

If the path parameter is invalid

throws
RuntimeException

If the Composer autoloader cannot be found

Return values
string —

The resolved application directory path

setEnvironment()

Set the environment type for the application.

private setEnvironment() : void

This function sets the environment type by defining the RAYDIUM_ENVIRONMENT_TYPE constant. If the environment type is not provided, it defaults to null and can fallback to .env file setup.

Usage:

  • If $environment is provided, it will define the RAYDIUM_ENVIRONMENT_TYPE.
  • If $environment is null, the function will allow the .env file to define the environment type.
Return values
void —

setErrorHandler()

Set up error handler for the application.

private setErrorHandler() : void
Return values
void —

setupContainer()

Set up the dependency injection container.

private setupContainer() : Bindings
Return values
Bindings —

Container bindings instance

setupEnvironment()

Set up the application environment.

private setupEnvironment(array<string|int, mixed> $envFiles, EnvType $envType, Container $psrContainer) : void
Parameters
$envFiles : array<string|int, mixed>

Environment files

$envType : EnvType

Environment type instance

$psrContainer : Container

PSR-11 container

Return values
void —

Search results