BaseYii setAlias()

setAlias() public static method

Registers a path alias.

A path alias is a short name representing a long path (a file path, a URL, etc.) For example, we use '@yii' as the alias of the path to the Yii framework directory.

A path alias must start with the character '@' so that it can be easily differentiated from non-alias paths.

Note that this method does not check if the given path exists or not. All it does is to associate the alias with the path.

Any trailing '/' and '\' characters in the given path will be trimmed.

See also getAlias().

public static void setAlias ( $alias, $path )
$alias string

The alias name (e.g. "@yii"). It must start with a '@' character. It may contain the forward slash '/' which serves as boundary character when performing alias translation by getAlias().

$path string

The path corresponding to the alias. If this is null, the alias will be removed. Trailing '/' and '\' characters will be trimmed. This can be

  • a directory or a file path (e.g. /tmp, /tmp/main.txt)
  • a URL (e.g. http://www.yiiframework.com)
  • a path alias (e.g. @yii/base). In this case, the path alias will be converted into the actual path first by calling getAlias().
throws yii\base\InvalidParamException

if $path is an invalid alias.

doc_Yii
2016-10-30 16:50:29
Comments
Leave a Comment

Please login to continue.