I've just installed yii2 basic project via composer and ran composer install
and composer update
. But I get the following error as it tries to open main.php
default layout page. the error says it cannot find the AppAsset class. How can I fix the issue ? this is the error:
Class 'app\assets\AppAsset' not found
By default, when you install yii2, a file AppAsset.php
will be created at: /path-to-application/assets/AppAssset.php
.
If, for some reason, it didn't, I would strongly recommend reinstall the framework, just in case of anything else is missing. Be sure you are following the tutorial
IF you just need this file, you can find its content here in the docs :
<?php
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
问题是因为我的gitignore文件,我已经将资产目录放入gitignore文件中,因此,当我从项目中克隆克隆时,找不到某些类。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.