L
L
lemon2212019-10-19 17:32:50
Yii
lemon221, 2019-10-19 17:32:50

Paths to files and resources on shared hosting Yiii2?

There is a yii2 project with the following structure
Site
-public_html
-admin
-Contents of the backend/web and htaccess
folders -Contents of the frontend/web
folder -yii
-backend
-common
-frontend
-vendor And so on
5dab1e2a55bc9641362956.png
Uploaded to shared hosting , as a rule it looks in the folder public_html
The project works but there is a problem with the paths
Wrote a module that is located in common/modules/module
in the module there is a folder assets/js, assets/img where js image files and other are stored
Problems with paths when connecting: cannot find files
Tried to use Aliases, absolute and relative paths, but nothing works
Only those files that are inside public_html are connected (everything outside is not connected, although the application is running)
There is no access to the server settings since it is shared hosting
How to specify paths?
5dab1e41d5285813238950.png

$this->registerJsFile('@common/modules/blog/assetrs/js/script.js',[
  'depends' => [\yii\web\JqueryAsset::className()]
]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-10-19
@lemon221

namespace common\modules\blog\assets;
use yii\web\AssetBundle;
/**
 * Main blog asset bundle.
 */
class BlogAsset extends AssetBundle
{
    public $sourcePath = '@common/modules/blog/assets';
    public $css = [
    ];
    public $js = [
        'js/script.js'
    ];
    public $depends = [
    ];
}

use common\modules\blog\assets\BlogAsset; 
BlogAsset::register($this);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question