S
S
Sergey2015-12-15 15:10:21
Yii
Sergey, 2015-12-15 15:10:21

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,
        ],

Placement task:
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',
    ];
}

The assets folder in the web directory is empty, what could be the reason?
"AssetManager" class and "publishDirectory" method:
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];
    }

It gives me:
string(55) "/home/httpd/vhosts/site.com/httpdocs/assets/d780c76"
bool(true)
Question: Why does the "is_dir" function return TRUE if the path doesn't exist yet (the assets folder is empty) ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korovin, 2015-12-15
@frost18

In access rights? Does the user running the web server have write access to this folder?

E
enchikiben, 2015-12-15
@EnChikiben

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 question

Ask a Question

731 491 924 answers to any question