How to import a new class in a new folder

Hi all:

I am a newer for Yii2。i had a new folder components with one file Controller.php





Controller.php:


    namespace app\controllers;


    use Yii;


    use yii\web\controller as YWController;


    class Controller extends YWController{}





but in another folder such as "controllers" :


    namespace app\controllers;


    class DefaultController extends Controller{}





  run and some mistake appeared as follow:


 


 PHP Fatal Error – yii\base\ErrorException





 Class 'app\controllers\Controller' not found








 why?


 thanks.

because of psr-4

class ‘app\controllers\Controller’ must be in path ‘@app/controller[size=“6”]s[/size]/Controller.php’

so, add ‘s’ to folder name