Cannot make model with yiic

Hi all.

I have read the tutorial to make a first application. But this probleme drives me crazy!!! :blink:

When i try to make the model in the yiic shell (model User user), the shell just exit with no error messages?!?!? Here’a the main.php

return array(







         'username' => 'root',

         'password' => '',




And when i check for the yii requirements, PDO extension and PDO MySQL extension passed

Please anyone, help me

the command is model <modelName> eg: model User or model user, not model User user

Thanks for the reply. But that does not work. I tried it… Any ideas?

when you create the webapp with yiic, you are in the framework folder, right?

when you enter the yiic shell, you are in the protected folder of your app

after altering the config, restart your console

yiic shell ../index.php

>>model User

>>crud User

this normally works

Yes. I follow these steps:

– intalled the yii framework in my htdoc directory

– under the framework folder create the webapp

– go under the protected folder of my new webapp and do yiic shell …/index.php

– The user table is already in my sql database

– model user: The program exits with no error messages…???

*** I tried after dropping the user table and it works with a warning… But the purpose would be that it works with the table already created!!!

Try changing your database host from ‘localhost’ to ‘’. I know the default for the new versions of mysql is to try to connect through the local socket file rather than actually making a database connection when you use the host ‘localhost’.

I ran into a lot of errors with connecting to the database because of this. More a matter of database configuration, but using allows you to still connect to localhost without changing your mysql conf.

If you still can’t get it to work, I recommend manually debugging the Model cli command to see where it is terminating and if it is getting to the point where it is executing the command.

You would want to debug this file: yii/framework/commands/shell/ModelCommand.php, function: run(), line: 236

Just add ‘die(“Got to here”);’ command in it until you find a point where it’s not getting to. From there, we can probably figure out more what is going wrong with it.

Just a guess, however I would try creating my app OUTSIDE the framework directory.

I’m getting to line 246




It’s like nothing is coming from the Yii::app()->getDb(). The die does not work after the if block. And still not work in the first line block…

Thanks but does not work either

I am not sure of your environment, but for me to get it to work (Windows XP/WAMP) I had to alter the shell script:

if "%PHP_COMMAND%" == "" set PHP_COMMAND=C:/wamp/bin/php/php5.2.9-2/php.exe

If that can help… My problem was that i had easyphp and xampp intalled on my system: I tried to install in xampp while using easyphp’s php.exe. Changing the php.exe path in the environment solve the problem.

Thank you to those who tried to help me

I had got exactly the same error. I tried all the recommendations in this post without success. Finally, after at least 2 hours debugging I found the problem:

In order to fill my needs I enabled the ‘accessControl’ filter in the SiteController.php file. Disabling the filter solved the problem.

You can also start yiic and specify the path to your main.php instead of index.php. Then you don’t have to change the accesscontrol each time you want to start the shell.