Answer the question
In order to leave comments, you need to log in
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
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?
$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
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 questionAsk a Question
731 491 924 answers to any question