Raydium Framework

EnvType
in package

Table of Contents

DEB  = 'deb'
DEBUG  = 'debug'
DEV  = 'dev'
DEVELOPMENT  = 'development'
LOCAL  = 'local'
PROD  = 'prod'
PRODUCTION  = 'production'
SEC  = 'sec'
SECURE  = 'secure'
STAGING  = 'staging'
$filesystem  : mixed
$envTypes  : array<string|int, mixed>
An array of all environment types.
__construct()  : mixed
createFile()  : void
filterFiles()  : array<string|int, mixed>
Filters out environment files that do not exist to avoid warnings.
getAll()  : array<string|int, string>
Get all environment types.
isValid()  : bool
Checks if the given type is a valid environment type.
randStr()  : string
Generate a cryptographically secure password.
read()  : array<string|int, mixed>
readOnly()  : array<string|int, string>
Reads the .env file and returns an array of environment variables.
supportedFiles()  : array<string|int, string>
Retrieves the default file names for environment configuration.
tryRegenerateFile()  : void
Regenerates the tenant-specific .env file if it doesn't exist.
generateFileContent()  : string
wpSalts()  : array<string|int, string>
convertSectionsToObjects()  : array<string|int, stdClass>
generateKioskFile()  : string
getValue()  : mixed
parseLine()  : array<string|int, string>
parseWithoutSections()  : array<string|int, mixed>
parseWithSections()  : array<string|int, mixed>
readEnvFile()  : array<string|int, string>
readFile()  : string
Lazy php7.4 pollyfill for Filesystem.

Constants

DEVELOPMENT

public mixed DEVELOPMENT = 'development'

PRODUCTION

public mixed PRODUCTION = 'production'

SECURE

public mixed SECURE = 'secure'

STAGING

public mixed STAGING = 'staging'

Properties

$filesystem

protected mixed $filesystem

$envTypes

An array of all environment types.

private static array<string|int, mixed> $envTypes = [self::SECURE, self::SEC, self::PRODUCTION, self::PROD, self::STAGING, self::DEVELOPMENT, self::DEV, self::DEBUG, self::DEB, self::LOCAL]

Methods

__construct()

public __construct(Filesystem $filesystem) : mixed
Parameters
$filesystem : Filesystem
Return values
mixed

createFile()

public createFile(string $filePath, string $domain[, string|null $prefix = null ]) : void
Parameters
$filePath : string
$domain : string
$prefix : string|null = null
Return values
void

filterFiles()

Filters out environment files that do not exist to avoid warnings.

public filterFiles(array<string|int, mixed> $envFiles, string $appPath) : array<string|int, mixed>
Parameters
$envFiles : array<string|int, mixed>
$appPath : string
Return values
array<string|int, mixed>

getAll()

Get all environment types.

public static getAll() : array<string|int, string>
Return values
array<string|int, string>

The list of environment types.

isValid()

Checks if the given type is a valid environment type.

public static isValid(null|string $type) : bool
Parameters
$type : null|string

The environment type to check.

Return values
bool

True if valid, false otherwise.

randStr()

Generate a cryptographically secure password.

public static randStr([int $length = 8 ][, bool $useSpecialChars = false ][, bool $startWithLetter = true ]) : string
Parameters
$length : int = 8

The length of the password to generate.

$useSpecialChars : bool = false

Whether to include special characters in the password.

$startWithLetter : bool = true

Whether to start the password with a letter.

Return values
string

The generated password.

read()

public read(string $envFilePath[, bool $sanitized = true ][, mixed $groupBySections = false ]) : array<string|int, mixed>
Parameters
$envFilePath : string
$sanitized : bool = true
$groupBySections : mixed = false
Return values
array<string|int, mixed>

readOnly()

Reads the .env file and returns an array of environment variables.

public readOnly(string $envFilePath) : array<string|int, string>
Parameters
$envFilePath : string
Tags
throws
FileNotFoundException

If the .env file does not exist.

throws
InvalidArgumentException

If the .env file contains invalid syntax.

psalm-return

array<string, string>

Return values
array<string|int, string>

supportedFiles()

Retrieves the default file names for environment configuration.

public static supportedFiles() : array<string|int, string>
Tags
since

[version number]

psalm-return

list{'env', '.env', '.env.secure', '.env.prod', '.env.staging', '.env.dev', '.env.debug', '.env.local', 'env.local'}

Return values
array<string|int, string>

An array of default file names for environment configurations.

tryRegenerateFile()

Regenerates the tenant-specific .env file if it doesn't exist.

public tryRegenerateFile(string $appPath, string $appHttpHost[, array<string|int, mixed> $availableFiles = [] ][, string|null $dbPrefix = null ]) : void
Parameters
$appPath : string
$appHttpHost : string
$availableFiles : array<string|int, mixed> = []
$dbPrefix : string|null = null
Return values
void

generateFileContent()

protected generateFileContent([string|null $wpdomain = null ][, string|null $prefix = null ]) : string
Parameters
$wpdomain : string|null = null
$prefix : string|null = null
Return values
string

wpSalts()

protected static wpSalts() : array<string|int, string>
Tags
psalm-return

array<string, string>

Return values
array<string|int, string>

convertSectionsToObjects()

private convertSectionsToObjects(array<string|int, mixed> $sections[, bool $sanitizeVal = true ]) : array<string|int, stdClass>
Parameters
$sections : array<string|int, mixed>
$sanitizeVal : bool = true
Tags
psalm-return

list{0?: stdClass,...}

Return values
array<string|int, stdClass>

generateKioskFile()

private generateKioskFile([string|null $wpdomain = null ]) : string
Parameters
$wpdomain : string|null = null
Return values
string

getValue()

private getValue(mixed $value[, bool $sanitized = true ]) : mixed
Parameters
$value : mixed
$sanitized : bool = true
Return values
mixed

parseLine()

private parseLine(string $line) : array<string|int, string>
Parameters
$line : string
Tags
psalm-return

list{string, string}

Return values
array<string|int, string>

parseWithoutSections()

private parseWithoutSections(array<string|int, mixed> $lines[, bool $sanitizeVal = true ]) : array<string|int, mixed>
Parameters
$lines : array<string|int, mixed>
$sanitizeVal : bool = true
Return values
array<string|int, mixed>

parseWithSections()

private parseWithSections(array<string|int, mixed> $lines) : array<string|int, mixed>
Parameters
$lines : array<string|int, mixed>
Return values
array<string|int, mixed>

readEnvFile()

private readEnvFile(string $envFilePath) : array<string|int, string>
Parameters
$envFilePath : string
Tags
psalm-return

non-empty-list

Return values
array<string|int, string>

readFile()

Lazy php7.4 pollyfill for Filesystem.

private readFile(string $filePath) : string
Parameters
$filePath : string
Return values
string

Search results