Documentation

Migrations extends BaseConfig
in package

Class BaseConfig

Not intended to be used on its own, this class will attempt to automatically populate the child class' properties with values from the environment.

These can be set within the .env file.

Table of Contents

$enabled  : bool
-------------------------------------------------------------------------- Enable/Disable Migrations --------------------------------------------------------------------------
$registrars  : array<string|int, mixed>
An optional array of classes that will act as Registrars for rapidly setting config class properties.
$table  : string
-------------------------------------------------------------------------- Migrations Table --------------------------------------------------------------------------
$timestampFormat  : string
-------------------------------------------------------------------------- Timestamp Format --------------------------------------------------------------------------
$didDiscovery  : bool
Has module discovery happened yet?
$moduleConfig  : Modules
The modules configuration.
__construct()  : mixed
Will attempt to get environment variables with names that match the properties of the child class.
getEnvValue()  : mixed
Retrieve an environment-specific configuration setting
initEnvValue()  : mixed
Initialization an environment-specific configuration setting
registerProperties()  : mixed
Provides external libraries a simple way to register one or more options into a config file.

Properties

$enabled

-------------------------------------------------------------------------- Enable/Disable Migrations --------------------------------------------------------------------------

public bool $enabled = true

Migrations are enabled by default.

You should enable migrations whenever you intend to do a schema migration and disable it back when you're done.

$registrars

An optional array of classes that will act as Registrars for rapidly setting config class properties.

public static array<string|int, mixed> $registrars = []

$table

-------------------------------------------------------------------------- Migrations Table --------------------------------------------------------------------------

public string $table = 'migrations'

This is the name of the table that will store the current migrations state. When migrations runs it will store in a database table which migration level the system is at. It then compares the migration level in this table to the $config['migration_version'] if they are not the same it will migrate up. This must be set.

$timestampFormat

-------------------------------------------------------------------------- Timestamp Format --------------------------------------------------------------------------

public string $timestampFormat = 'Y-m-d-His_'

This is the format that will be used when creating new migrations using the CLI command:

php spark migrate:create

Typical formats:

  • YmdHis_
  • Y-m-d-His_
  • Y_m_d_His_

$didDiscovery

Has module discovery happened yet?

protected static bool $didDiscovery = false

Methods

__construct()

Will attempt to get environment variables with names that match the properties of the child class.

public __construct() : mixed

The "shortPrefix" is the lowercase-only config class name.

Return values
mixed

getEnvValue()

Retrieve an environment-specific configuration setting

protected getEnvValue(string $property, string $prefix, string $shortPrefix) : mixed
Parameters
$property : string
$prefix : string
$shortPrefix : string
Return values
mixed

initEnvValue()

Initialization an environment-specific configuration setting

protected initEnvValue(mixed &$property, string $name, string $prefix, string $shortPrefix) : mixed
Parameters
$property : mixed
$name : string
$prefix : string
$shortPrefix : string
Return values
mixed

registerProperties()

Provides external libraries a simple way to register one or more options into a config file.

protected registerProperties() : mixed
Tags
throws
ReflectionException
Return values
mixed

Search results