publish() public method
Publishes a file or a directory.
This method will copy the specified file or directory to $basePath so that it can be accessed via the Web server.
If the asset is a file, its file modification time will be checked to avoid unnecessary file copying.
If the asset is a directory, all files and subdirectories under it will be published recursively. Note, in case $forceCopy is false the method only checks the existence of the target directory to avoid repetitive copying (which is very expensive).
By default, when publishing a directory, subdirectories and files whose name starts with a dot "." will NOT be published. If you want to change this behavior, you may specify the "beforeCopy" option as explained in the $options
parameter.
Note: On rare scenario, a race condition can develop that will lead to a one-time-manifestation of a non-critical problem in the creation of the directory that holds the published assets. This problem can be avoided altogether by 'requesting' in advance all the resources that are supposed to trigger a 'publish()' call, and doing that in the application deployment phase, before system goes live. See more in the following discussion: http://code.google.com/p/yii/issues/detail?id=2579
public array publish ( $path, $options = [] ) | ||
---|---|---|
$path | string |
The asset (file or directory) to be published |
$options | array |
The options to be applied when publishing a directory. The following options are supported:
|
return | array |
The path (directory or file path) and the URL that the asset is published as. |
throws | yii\base\InvalidParamException |
if the asset to be published does not exist. |
Please login to continue.