3

I have duplicated /frontend folder into /api removed unnecessary code like views. And then I started to generate using gii the new module eg: v1

I got this error message when using api\modules namespace.

Module class must be properly namespaced.

enter image description here

1 Answer 1

4

You may not be aware but in the Yii2 framework there is a common/config/bootstrap.php file which holds the aliases eg: @frontend, @common

Just add another line for the /api folder section and it would be good.

Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
Yii::setAlias('@api', dirname(dirname(__DIR__)) . '/api');
Sign up to request clarification or add additional context in comments.

1 Comment

well, the alias could be added to the params-local.php file too if you want to, and it would be detected in the gii module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.