Command Line Gii throwing errors

I’ve worked in a Yii2 environment before, but this is my first time starting a project with Yii2.

I created a new project with the advanced template and everything seems to be working properly. However, I’m having issues getting gii to work from the command line.

I ran

php yii gii/model --modelClass=Client --tableName=client

and it created the model correctly, however it created it in the console/models folders. Ideally I would like to create it in common\models, however attempting to create the model with --modelClass=common\models\Client simply asks if I want to create the model "commonmodelsClient".

Beyond that, I want to create a CRUD controller with

php yii gii/crud --controllerClass=ClientController --modelClass=Client

but I just get the errors:

 - modelClass: Class 'Client' does not exist or has syntax error.

 - controllerClass: The class name must contain fully qualified namespace name.

I’ve tried adding namespaces at varying points like --modelClass=app\models\Client, but again get the “appmodelsClient” issue. Likewise if I try to say --controllerClass=app\controllers\ClientController I get an error about the controller needing to start with a capital letter.

I’m sure this is just me not understanding what formatting the commands expect, but I wasn’t able to find any specifics in the documentation other than the example for

php yii gii/model --tableName=city --modelClass=City

Special characters should be escaped in command line.

How should they be escaped? I’ve tried escaping each \ with another \ for common\\models\\Client, but that throws the error

 - modelClass: Only word characters are allowed.

putting it in quotes such as --modelClass="common\models\Client" gives the same error.

try adding two slashes


I’ve done that, I get the following error:

 - modelClass: Only word characters are allowed.

Oh, sorry. Indeed, model name should be specified without namespace and namespace could be specified with additional --ns so full command will look like the following:

./yii gii/model --modelClass=Client --tableName=client --ns=common\\models