App ​
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\App
- Since
- 3.0.0
App helper.
Public Methods ​
Method | Description |
---|---|
assetManagerConfig() | Returns the assetManager component config for web requests. |
backtrace() | Returns the backtrace as a string (omitting the final frame where this method was called). |
cacheConfig() | Returns the cache component config. |
checkForValidIconv() | Returns whether the server has a valid version of the iconv extension installed. |
createFormattingLocale() | Creates a locale object that should be used for date and number formatting. |
dbConfig() | Returns the db component config. |
dbMutexConfig() | Returns a database-based mutex driver config. |
defaultLogTargets() | Returns the default log targets. |
editionHandle() | Returns the handle of the given Craft edition. |
editionIdByHandle() | Returns the ID of a Craft edition by its handle. |
editionName() | Returns the name of the given Craft edition. |
editions() | Returns an array of all known Craft editions’ IDs. |
env() | Returns an environment variable, checking for it in $_SERVER and calling getenv() as a fallback. |
extensionVersion() | Returns a PHP extension version, without the distribution info. |
humanizeClass() | Returns a humanized class name. |
isEphemeral() | Returns whether Craft is running on an environment with ephemeral storage. |
isNitro() | Returns whether Craft is running within Nitro v1. |
isPathAllowed() | Returns whether the given path is within PHP’s open_basedir setting. |
isValidEdition() | Returns whether an edition is valid. |
licenseKey() | |
logConfig() | Returns the log component config. |
mailSettings() | Returns the system email settings. |
mailerConfig() | Returns the mailer component config. |
maxPowerCaptain() | Sets PHP’s memory limit to the maximum specified by the config3:phpMaxMemoryLimit config setting, and gives the script an unlimited amount of time to execute. |
mutexConfig() | Returns a file-based mutex driver config. |
normalizePhpPaths() | Normalizes a PHP path setting to an array of paths |
normalizeVersion() | Removes distribution info from a version |
parseBooleanEnv() | Checks if a string references an environment variable ($VARIABLE_NAME ) and returns the referenced boolean value, or null if a boolean value can’t be determined. |
parseEnv() | Checks if a string references an environment variable ($VARIABLE_NAME ) and/or an alias (@aliasName ), and returns the referenced value. |
phpConfigValueAsBool() | Retrieves a bool PHP config setting and normalizes it to an actual bool. |
phpConfigValueAsPaths() | Retrieves a file path PHP config setting and normalizes it to an array of paths. |
phpConfigValueInBytes() | Retrieves a disk size PHP config setting and normalizes it into bytes. |
phpExecutable() | Returns the path to a PHP executable which should be used by sub processes. |
phpSizeToBytes() | Normalizes a PHP file size into bytes. |
phpVersion() | Returns the PHP version, without the distribution info. |
projectConfigConfig() | Returns the projectConfig component config. |
sessionConfig() | Returns the session component config for web requests. |
supportsIdn() | Returns whether the server supports IDNA ASCII strings. |
testIniSet() | Tests whether ini_set() works. |
userConfig() | Returns the user component config for web requests. |
viewConfig() | Returns the view component config. |
webRequestConfig() | Returns the request component config for web requests. |
webResponseConfig() | Returns the response component config for web requests. |
assetManagerConfig()
​
- Since
- 3.0.18
Returns the assetManager
component config for web requests.
Returns ​
backtrace()
​
- Since
- 3.0.13
Returns the backtrace as a string (omitting the final frame where this method was called).
Arguments ​
$limit
(integer) – The max number of stack frames to be included (0 means no limit)
Returns ​
cacheConfig()
​
- Since
- 3.0.18
Returns the cache
component config.
Returns ​
checkForValidIconv()
​
Returns whether the server has a valid version of the iconv extension installed.
Returns ​
createFormattingLocale()
​
- Since
- 3.6.0
Creates a locale object that should be used for date and number formatting.
Returns ​
dbConfig()
​
- Since
- 3.0.18
Returns the db
component config.
Arguments ​
$dbConfig
(craft\config\DbConfig, null) – The database config settings
Returns ​
dbMutexConfig()
​
DEPRECATED
Deprecated in 3.7.30. Database-based mutex locking is no longer recommended.
- Since
- 3.5.18
Returns a database-based mutex driver config.
Returns ​
defaultLogTargets()
​
- Since
- 3.6.14
Returns the default log targets.
Returns ​
editionHandle()
​
- Since
- 3.1.0
Returns the handle of the given Craft edition.
Arguments ​
$edition
(integer) – An edition’s ID.
Returns ​
string – The edition’s name.
editionIdByHandle()
​
- Since
- 3.1.0
Returns the ID of a Craft edition by its handle.
Arguments ​
$handle
(string) – An edition’s handle
Returns ​
integer – The edition’s ID
Throws ​
- yii\base\InvalidArgumentException
if $handle is invalid
editionName()
​
Returns the name of the given Craft edition.
Arguments ​
$edition
(integer) – An edition’s ID.
Returns ​
string – The edition’s name.
editions()
​
Returns an array of all known Craft editions’ IDs.
Returns ​
array – All the known Craft editions’ IDs.
env()
​
- Since
- 3.4.18
Returns an environment variable, checking for it in $_SERVER
and calling getenv()
as a fallback.
Arguments ​
$name
(string) – The environment variable name
Returns ​
string, array, false – The environment variable value
extensionVersion()
​
Returns a PHP extension version, without the distribution info.
Arguments ​
$name
(string) – The extension name
Returns ​
humanizeClass()
​
Returns a humanized class name.
Arguments ​
$class
(string)
Returns ​
isEphemeral()
​
- Since
- 3.4.0
Returns whether Craft is running on an environment with ephemeral storage.
Returns ​
isNitro()
​
DEPRECATED
Deprecated in 3.7.9.
- Since
- 3.4.19
Returns whether Craft is running within Nitro v1.
Returns ​
isPathAllowed()
​
- Since
- 3.7.34
Returns whether the given path is within PHP’s open_basedir
setting.
Arguments ​
$path
(string)
Returns ​
isValidEdition()
​
Returns whether an edition is valid.
Arguments ​
$edition
(mixed
) – An edition’s ID (or is it?)
Returns ​
boolean – Whether $edition is a valid edition ID.
licenseKey()
​
Returns ​
logConfig()
​
DEPRECATED
Deprecated in 3.6.0. Override components.log.targets
instead
- Since
- 3.0.18
Returns the log
component config.
Returns ​
mailSettings()
​
- Since
- 3.1.0
Returns the system email settings.
Returns ​
mailerConfig()
​
- Since
- 3.0.18
Returns the mailer
component config.
Arguments ​
$settings
(craft\models\MailSettings, null) – The system mail settings
Returns ​
array{class: class-string<\craft\mail\Mailer>}
maxPowerCaptain()
​
Sets PHP’s memory limit to the maximum specified by the config3:phpMaxMemoryLimit config setting, and gives the script an unlimited amount of time to execute.
mutexConfig()
​
- Since
- 3.0.18
Returns a file-based mutex driver config.
TIP
If you were calling this to override the yii\mutex\FileMutex::$isWindows property, note that overriding the mutex
component may no longer be necessary, as Craft no longer uses a mutex when Dev Mode is enabled.
Returns ​
normalizePhpPaths()
​
- Since
- 3.7.34
Normalizes a PHP path setting to an array of paths
Arguments ​
$value
(string) – The PHP path setting value
Returns ​
string[] – The normalized paths
normalizeVersion()
​
Removes distribution info from a version
Arguments ​
$version
(string)
Returns ​
parseBooleanEnv()
​
- Since
- 3.7.29
Checks if a string references an environment variable ($VARIABLE_NAME
) and returns the referenced boolean value, or null
if a boolean value can’t be determined.
Arguments ​
$value
(mixed
)
Returns ​
Example ​
$status = App::parseBooleanEnv('$SYSTEM_STATUS') ?? false;
parseEnv()
​
- Since
- 3.7.29
Checks if a string references an environment variable ($VARIABLE_NAME
) and/or an alias (@aliasName
), and returns the referenced value.
If the string references an environment variable with a value of true
or false
, a boolean value will be returned.
Arguments ​
Returns ​
string, boolean, null – The parsed value, or the original value if it didn’t reference an environment variable and/or alias.
Example ​
$value1 = App::parseEnv('$SMTP_PASSWORD');
$value2 = App::parseEnv('@webroot');
phpConfigValueAsBool()
​
Retrieves a bool PHP config setting and normalizes it to an actual bool.
Arguments ​
$var
(string) – The PHP config setting to retrieve.
Returns ​
boolean – Whether it is set to the php.ini equivalent of true
.
phpConfigValueAsPaths()
​
- Since
- 3.7.34
Retrieves a file path PHP config setting and normalizes it to an array of paths.
Arguments ​
$var
(string) – The PHP config setting to retrieve
Returns ​
string[] – The normalized paths
phpConfigValueInBytes()
​
- Since
- 3.0.38
Retrieves a disk size PHP config setting and normalizes it into bytes.
Arguments ​
$var
(string) – The PHP config setting to retrieve.
Returns ​
integer, float – The value normalized into bytes.
phpExecutable()
​
- Since
- 3.9.4
Returns the path to a PHP executable which should be used by sub processes.
Returns ​
string, null – The PHP executable path, or null
if it can’t be determined.
phpSizeToBytes()
​
- Since
- 3.6.0
Normalizes a PHP file size into bytes.
Arguments ​
$value
(string) – The file size expressed in PHP config value notation
Returns ​
integer, float – The value normalized into bytes.
phpVersion()
​
Returns the PHP version, without the distribution info.
Returns ​
projectConfigConfig()
​
Returns the projectConfig
component config.
sessionConfig()
​
- Since
- 3.0.18
Returns the session
component config for web requests.
Returns ​
supportsIdn()
​
- Since
- 3.7.9
Returns whether the server supports IDNA ASCII strings.
Returns ​
testIniSet()
​
- Since
- 3.0.40
Tests whether ini_set() works.
Returns ​
userConfig()
​
- Since
- 3.0.18
Returns the user
component config for web requests.
Returns ​
viewConfig()
​
- Since
- 3.0.18
Returns the view
component config.
Returns ​
webRequestConfig()
​
- Since
- 3.0.18
Returns the request
component config for web requests.
Returns ​
webResponseConfig()
​
- Since
- 3.3.0
Returns the response
component config for web requests.