I need help making my first Asset Bundle to work

Hello,all.I have generated an app called london and in the assets directory,i have AppAsset.php which looks like this


<?php

namespace app\assets;

use yii\web\AssetBundle;


class AppAsset extends AssetBundle

{

    public $basePath = '@webroot';

    public $baseUrl = '@web';

    public $css = [

         'css/app.css',

    ];

    public $js = [

        'js/app.js',

    ];

    public $depends = [

        'yii\web\YiiAsset',

        'yii\bootstrap\BootstrapAsset',

    ];

}

?>

I have then gone under my views site directory and created this view


<?php

use yii\helpers\Html;

use app\assets\AppAsset;

AppAsset::register($this); 

?>

<h1 class="lead">Hello <?= $droid ?></h1>

<p>Welcome to your Yii2 demonstration application.</p>

and when i run the controller that renders the view,it gives me

Can someone guide me on how to make my asset bundle work.

Have you stored your AppAsset class in the "assets" subfolder of your root directory? The autoloader will use the namespace to find the location of the class. If your AppAsset class is in another folder, you need to change the namespace.

The AppAsset.php is inside the asset directory but i discovered that i was using Yii 1.x so i installed 2 and the problem was solved.

Thanks for your help.

I have problem but i dont understand why I can create new topic in this forum :(