Craft
- Type
- Class
- Inherits
- Craft »
Yii
- Since
- 3.0.0
Craft is helper class serving common Craft and Yii framework functionality.
It encapsulates \Yii
and ultimately yii\BaseYii, which provides the actual implementation.
Public Methods
Method | Description |
---|---|
autoload() | Class autoloader. |
cookieConfig() | Generates and returns a cookie config. |
createGuzzleClient() | Creates a Guzzle client configured with the given array merged with any default values in config/guzzle.php. |
createObject() | |
dd() | Displays a variable and ends the request. (“Dump and die”) |
dump() | Displays a variable. |
getAlias() | |
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. |
autoload()
Class autoloader.
Arguments
$className
(class-string
)
cookieConfig()
Generates and returns a cookie config.
Arguments
$config
(array) – Any config options that should be included in the config.$request
(\Request
, null) – The request object
Returns
array – The cookie config array.
createGuzzleClient()
Creates a Guzzle client configured with the given array merged with any default values in config/guzzle.php.
Arguments
$config
(array) – Guzzle client config settings
Returns
\Client
createObject()
Arguments
Returns
\T
dd()
Displays a variable and ends the request. (“Dump and die”)
Arguments
$var
(mixed
) – The variable to be dumped.$depth
(integer) – The maximum depth that the dumper should go into the variable.$highlight
(boolean) – Whether the result should be syntax-highlighted.
Throws
\ExitException
if the application is in testing mode
dump()
Displays a variable.
Arguments
$var
(mixed
) – The variable to be dumped.$depth
(integer) – The maximum depth that the dumper should go into the variable.$highlight
(boolean) – Whether the result should be syntax-highlighted.$return
(boolean) – Whether the dump result should be returned instead of output.
Returns
string, null – The output, if $return
is true
getAlias()
Arguments
$alias
$throwException
parseBooleanEnv()
DEPRECATED
Deprecated in 3.7.29. App::parseBooleanEnv()
should be used instead.
- Since
- 3.7.22
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 = Craft::parseBooleanEnv('$SYSTEM_STATUS') ?? false;
parseEnv()
DEPRECATED
Deprecated in 3.7.29. App::parseEnv()
should be used instead.
- Since
- 3.1.0
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, null, false – The parsed value, or the original value if it didn’t reference an environment variable or alias.
Example
$value1 = Craft::parseEnv('$SMTP_PASSWORD');
$value2 = Craft::parseEnv('@webroot');
Constants
Constant | Description |
---|---|
Pro | |
Solo |