[Solved] Can't run yiic shell

Hi everyone,

I was searching the best framework which would suit to what I want to do. I found Yii which looks great. So first of all, thanks for the work you've already done!

Now, I’m trying to duplicate the blog tutorial and fail at the scaffolding step. I use protable Xampp Lite 1.7.0 and have created a web application thanks to yiic webapp.

But when I try tu run yiic shell i have two different behaviours.

If I try to run yiic shell index.php, or any variation with or without paths, I can type the first command line “model User”. But after that PHP CLI is closed, nothing is done and I come back to the ms-dos command line.

If I try to run the command line specifying php.ini file I get this error message :

Quote

J:\Serveur-web\www\blogyii>php -c php.ini j:\serveur-web\yii\framework\yiic.php

shell j:\serveur-web\www\blogyii\index.php

Yii Interactive Tool v1.0 (based on Yii v1.0.7)

Please type 'help' for help. Type 'exit' to quit.

>> model User

Warning: include(PDO.php): failed to open stream: No such file or directory in J

:\Serveur-web\yii\framework\YiiBase.php on line 316

Warning: include(): Failed opening 'PDO.php' for inclusion (include_path='.;C:\p

hp5\pear;J:\Serveur-web\www\blogyii\protected\models;J:\Serveur-web\www\blogyii\

protected\components') in J:\Serveur-web\yii\framework\YiiBase.php on line 316

Fatal error: Class 'PDO' not found in J:\Serveur-web\yii\framework\db\CDbConnect

ion.php on line 282

Actually there is only one php.ini file in Xampp Lite.

I did some research on the website and the forum. As you can guess, I didn't find any answer to this problem.

Is there somebody to help me?

Kind regards,

Bruno.

Please make sure PHP PDO ext is enabled in php.ini.

Sorry, I forgot to tell you about it!

I’ve checked the requirements, PDO extension and PDO Extension for MySQL are installed.

Quote

PDO

PDO support => enabled

PDO drivers => mssql, mysql, sqlite2

pdo_mysql

PDO Driver for MySQL, client library version => 5.1.30

Any idea?

PS : I don’t know if it’s important, but yii is at the same level than wwwroot, not in wwwroot. I use windows vista and set the path environment variable to the correct value (I can run yiic webapp blog)

i think you need to add PEAR in you include path as well.

PEAR! Why?

I’m playing with MySQL users. If I create a user like this :

User    |  Host   | Password  | Global privileges   | Grant

bruno  | %    | Yes    | ALL PRIVILEGES  | Yes

I get this error :

Quote

>> model User

exception 'CDbException' with message 'CDbConnection failed to open the DB connection:

SQLSTATE[28000] [1045] Access denied for user 'bruno'@'localhost' (using password: YES)'

in J:\Serveur-web\yii\framework\db\CDbConnection.php:248

Stack trace:

#0 J:\Serveur-web\yii\framework\db\CDbConnection.php(223): CDbConnection->open()

#1 J:\Serveur-web\yii\framework\db\CDbConnection.php(202): CDbConnection->setActive(true)

#2 J:\Serveur-web\yii\framework\base\CModule.php(353): CDbConnection->init()

#3 J:\Serveur-web\yii\framework\base\CApplication.php(338): CModule->getComponent('db')

#4 J:\Serveur-web\yii\framework\cli\commands\shell\ModelCommand.php(267): CApplication->getDb()

#5 J:\Serveur-web\yii\framework\cli\commands\ShellCommand.php(142): ModelCommand->run(Array)

#6 J:\Serveur-web\yii\framework\cli\commands\ShellCommand.php(99): ShellCommand->runShell()

#7 J:\Serveur-web\yii\framework\console\CConsoleCommandRunner.php(62): ShellCommand->run(Array)

#8 J:\Serveur-web\yii\framework\console\CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#9 J:\Serveur-web\yii\framework\base\CApplication.php(133): CConsoleApplication->processRequest()

#10 J:\Serveur-web\yii\framework\yiic.php(31): CApplication->run()

#11 J:\Serveur-web\yii\framework\yiic(15): require_once('J:\Serveur-web…')

#12 {main}

If I create the same user as root :

User    |  Host     | Password  | Global privileges   | Grant

bruno  | 127.0.0.1 | Yes  | ALL PRIVILEGES      | Yes

bruno  | localhost | Yes  | ALL PRIVILEGES      | Yes

Nothing happens.

This is the databse setup :

‘db’=>array(

  'class'=>'CDbConnection',

  'connectionString'=>'mysql:host=localhost;dbname=blogyii',

  'username'=>'bruno',

  'password'=>'pwd',

),

I continue to try to create a blog on portable xamppLite on an USB key.

Actually, I succeed to do the scaffolding on another environment. But I need to run everything on this USB key.

So for the previous error, I’m searching a solution in the MySQL documentation. But I have another weird behaviour. If I use the root user in the connection string, I get this :

Quote

Fatal error: Cannot redeclare class Yii in J:\Developpement\Serveur-web\yii\framework\yii.php on line 29
This means nothing to me.

Any idea?

Well I've changed of wamp environment and it solved it. I don't know why. For information, I'm now using easyphp.

well that’s good coz i have same problem , how d id u solve it in the wamp server ?? coz i m using it

I was just stuck on this. The problem was that I have yii framework in my path. When I typed "yiic shell" it was using the one from my path, whereas if I typed "protected/yiic shell" then I got a console.