Answer the question
In order to leave comments, you need to log in
Resource files are not published in Yii2, where to look for an error?
Everything works on the local server, but when I upload it to the hosting, the "assets" folder is empty.
Component settings:
'components' => [
'assetManager' => [
'linkAssets' => true,
],
class BackAsset extends AssetBundle{
public $sourcePath = '@app/widgets/d_back/assets';
public $baseUrl = '@webroot';
public $css = [
'css\d_back.css',
];
public $js = [];
public $depends = [
'app\assets\AppAsset',
];
}
protected function publishDirectory($src, $options)
{
$dir = $this->hash($src);
$dstDir = $this->basePath . DIRECTORY_SEPARATOR . $dir;
if ($this->linkAssets) {
var_dump($dstDir);
echo '<br/>';
var_dump(is_dir($dstDir));
exit();
if (!is_dir($dstDir)) {
symlink($src, $dstDir);
}
} elseif (!empty($options['forceCopy']) || ($this->forceCopy && !isset($options['forceCopy'])) || !is_dir($dstDir)) {
$opts = array_merge(
$options,
[
'dirMode' => $this->dirMode,
'fileMode' => $this->fileMode,
]
);
if (!isset($opts['beforeCopy'])) {
if ($this->beforeCopy !== null) {
$opts['beforeCopy'] = $this->beforeCopy;
} else {
$opts['beforeCopy'] = function ($from, $to) {
return strncmp(basename($from), '.', 1) !== 0;
};
}
}
if (!isset($opts['afterCopy']) && $this->afterCopy !== null) {
$opts['afterCopy'] = $this->afterCopy;
}
FileHelper::copyDirectory($src, $dstDir, $opts);
}
return [$dstDir, $this->baseUrl . '/' . $dir];
}
Answer the question
In order to leave comments, you need to log in
In access rights? Does the user running the web server have write access to this folder?
you have symbolic links linkAssets enabled in this case no copying occurs
www.yiiframework.com/doc-2.0/yii-web-assetmanager....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question