TheDevWay
TheDevWay

Reputation: 1413

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 . 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

Upvotes: 1

Views: 7751

Answers (2)

TheDevWay
TheDevWay

Reputation: 1413

The problem was because of my gitignore file, I have put the asset directory in to the gitignore file by accident and because of that, when I git cloned from the project some classes were not found.

Upvotes: 1

Clyff
Clyff

Reputation: 4076

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

Upvotes: 3

Related Questions