[英]Class 'app\assets\AppAsset' not found issue in yii2
I've just installed yii2 basic project via composer and ran composer install
and composer update
. 我刚刚通过composer安装了yii2基本项目并运行了
composer install
和composer update
。 But I get the following error as it tries to open main.php
default layout page. 但是我尝试打开
main.php
默认布局页面时收到以下错误。 the error says it cannot find the AppAsset class. 错误说它无法找到AppAsset类。 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
. 默认情况下,安装yii2时,将在以下位置创建文件
AppAsset.php
: /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文件中,因此,当我从项目中克隆克隆时,找不到某些类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.