Yii Framework Forum: Error when running yiic shell - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error when running yiic shell Rate Topic: -----

#1 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 01 December 2008 - 10:00 PM

Hi all,

As a great advocate of Prado, it's great to see Yii is the new generation!  Looks great, but I'm having some problems getting the first app to run.

I'm using the tutorial in the help documentation and am at the point "Implementing CRUD Operations"  When I run the yiic shell command, I receive the following error.. something to do with session permissions:
PHP Error

Description

session_start(): open(/var/lib/php/session/sess_cc12q9s8sd2roauf9v5au6htj2, O_RDWR) failed: Permission denied (13)

Source File

/var/www/html/dev/yii/framework/web/CHttpSession.php(102)


00090:        return false;
00091:    }
00092:
00093:    /**
00094:      * Starts the session if it has not started yet.
00095:      */
00096:    public function open()
00097:    {
00098:        if(session_id()==='')
00099:        {
00100:            if($this->getUseCustomStorage())
00101:                session_set_save_handler(array($this,'openSession'),array($this,'closeSession'),array($this,'readSession'),array($this,'writeSession'),array($this,'destroySession'),array($this,'gcSession'));
00102:            session_start();


00103:        }
00104:    }
00105:
00106:    /**
00107:      * Ends the current session and store session data.
00108:      */
00109:    public function close()
00110:    {
00111:        if(session_id()!=='')
00112:            @session_write_close();
00113:    }
00114:




Stack Trace


#0 /var/www/html/dev/yii/framework/web/CHttpSession.php(102): session_start()
#1 /var/www/html/dev/yii/framework/web/CHttpSession.php(75): CHttpSession->open()
#2 /var/www/html/dev/yii/framework/core/CApplication.php(710): CHttpSession->init()
#3 /var/www/html/dev/yii/framework/web/CWebApplication.php(227): CWebApplication->getComponent()
#4 /var/www/html/dev/yii/framework/web/auth/CWebUser.php(83): CWebApplication->getSession()
#5 /var/www/html/dev/yii/framework/core/CApplication.php(710): CWebUser->init()
#6 /var/www/html/dev/yii/framework/core/CApplication.php(132): CWebApplication->getComponent()
#7 /var/www/html/dev/yiitest/testdrive/protected/views/site/index.php(2): CWebApplication->__get()
#8 /var/www/html/dev/yii/framework/web/CBaseController.php(119): require()
#9 /var/www/html/dev/yii/framework/web/CBaseController.php(88): SiteController->renderInternal()
#10 /var/www/html/dev/yii/framework/web/CController.php(482): SiteController->renderFile()
#11 /var/www/html/dev/yii/framework/web/CController.php(417): SiteController->renderPartial()
#12 /var/www/html/dev/yiitest/testdrive/protected/controllers/SiteController.php(27): SiteController->render()
#13 /var/www/html/dev/yii/framework/web/actions/CInlineAction.php(32): SiteController->actionIndex()
#14 /var/www/html/dev/yii/framework/web/CController.php(207): CInlineAction->run()
#15 /var/www/html/dev/yii/framework/web/CController.php(192): SiteController->runAction()
#16 /var/www/html/dev/yii/framework/web/CController.php(167): SiteController->runActionWithFilters()
#17 /var/www/html/dev/yii/framework/web/CWebApplication.php(146): SiteController->run()
#18 /var/www/html/dev/yii/framework/web/CWebApplication.php(118): CWebApplication->runController()
#19 /var/www/html/dev/yii/framework/core/CApplication.php(146): CWebApplication->processRequest()
#20 /var/www/html/dev/yiitest/testdrive/index.php(11): CWebApplication->run()
#21 /var/www/html/dev/yii/framework/cli/commands/ShellCommand.php(68): require()
#22 /var/www/html/dev/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run()
#23 /var/www/html/dev/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run()
#24 /var/www/html/dev/yii/framework/core/CApplication.php(146): CConsoleApplication->processRequest()
#25 /var/www/html/dev/yii/framework/yiic.php(30): CConsoleApplication->run()
#26 /var/www/html/dev/yii/framework/yiic(15): require_once()




Any help would be appreciated.

R
P.S. I'm running Fedora 8, php 5.2x, pdo seems to be there and working. 

0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 01 December 2008 - 10:08 PM

As the error says, you don't have permission to write in /var/lib/php/session.
You may need to check what php.ini is being used by your php command line program (it could be different from the online one). Also make sure the session temp directory is writable.
0

#3 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 01 December 2008 - 11:09 PM

Thanks Qianq, it got me past the first step.  I had to run it under different permissions.  yiic shell runs fine and I get teh >> prompt.

But, when I type model User<enter>, I get
exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /var/www/html/dev/yii/framework/db/CDbConnection.php:226
Stack trace:
#0 /var/www/html/dev/yii/framework/db/CDbConnection.php(201): CDbConnection->open()
#1 /var/www/html/dev/yii/framework/db/CDbConnection.php(180): CDbConnection->setActive(true)
#2 /var/www/html/dev/yii/framework/core/CApplication.php(710): CDbConnection->init()
#3 /var/www/html/dev/yii/framework/core/CApplication.php(361): CApplication->getComponent('db')
#4 /var/www/html/dev/yii/framework/cli/commands/shell/ModelCommand.php(92): CApplication->getDb()
#5 [internal function]: ModelCommand->generateModel('/var/www/html/d...', Array)
#6 /var/www/html/dev/yii/framework/console/CConsoleCommand.php(116): call_user_func(Array, '/var/www/html/d...', Array)
#7 /var/www/html/dev/yii/framework/cli/commands/shell/ModelCommand.php(72): CConsoleCommand->copyFiles(Array)
#8 /var/www/html/dev/yii/framework/cli/commands/ShellCommand.php(95): ModelCommand->run(Array)
#9 /var/www/html/dev/yii/framework/cli/commands/ShellCommand.php(75): ShellCommand->runShell()
#10 /var/www/html/dev/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)
#11 /var/www/html/dev/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#12 /var/www/html/dev/yii/framework/core/CApplication.php(146): CConsoleApplication->processRequest()
#13 /var/www/html/dev/yii/framework/yiic.php(30): CApplication->run()
#14 /var/www/html/dev/yii/framework/yiic(15): require_once('/var/www/html/d...')
#15 {main}


This type of error is mentioned in the manual regarding using the incorrect PHP CLI or php.ini file.  I'm not sure how to use the "correct" php cli, since I believe there is only one.  As far as the php.ini file, i ran it with the -n switch(no ini) and the -c(specified the php.ini in the live environment).  In either case, I receive the same error. 

Any ideas?

Thanks,

R


0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 02 December 2008 - 07:41 AM

With -c switch, could you check your php.ini and make sure it has enabled PDO and the specific PDO DB driver?
0

#5 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 02 December 2008 - 08:21 AM

Hi Qiang,

My pdo.so and pdo_mysql.so are in the extension_dir referenced by php.ini.  When I run phpinfo(), they are there and enabled.  The pdo_mysql version is 5.0.45.

Thanks,

R
0

#6 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 02 December 2008 - 08:33 AM

Did you run phpinfo() in command line?
0

#7 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 02 December 2008 - 08:45 AM

yes, I ran it with the php -c(path to php.ini) and without to see if I was getting the same result, which I am. 

The partial output is as follows:

PDO

PDO support => enabled
PDO drivers => mysql, sqlite

pdo_mysql

PDO Driver for MySQL, client library version => 5.0.45

0

#8 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 02 December 2008 - 09:52 AM

I got it working!  This had nothing to do with the php cli, but it was the incorrect syntax for the pdo connection string. 

This is what I used in case anyone else runs into the problem:
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=yourDbName',
'username'=>'yourUsernam',
'password'=>'yourPassword',
),


Thanks for your help Qiang!

R
0

#9 User is offline   loupblanc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-May 09

Posted 08 May 2009 - 11:48 AM

I'd rather continue posting in this topic than start a new one as I'm basically having the same problem as outlined in post #1

I've tried running the script with the php cli (php -c /path/to/php.ini etc..) and it made no difference.

Now the only thing I can think of is the fact that all session files in /var/lib/php/session/ belong to apache:apache as opposed to [user]:[group] in the website I'm trying to get yii to work. However I'm not sure how to modify my php.ini to make that work...

For info I run php 5.1.6 and all sub-sites point to the same php.ini file.

So if anyone has ideas what to do to get the yii shell to run that'd be appreciated.

Thanks :)
0

#10 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 08 May 2009 - 11:57 AM

What about changing the permission of the session directory? Since yiic shell is mainly used on dev machine, you should have full control of it.
0

#11 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 08 May 2009 - 12:04 PM

When I originally had this problem, it was because I was logged in as a user with restricted permissions.  When I logged in as admin, since it was a dev machine, it worked fine. 

R
0

#12 User is offline   loupblanc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-May 09

Posted 11 May 2009 - 09:29 AM

Right I changed the permissions in my /sessions folder and that got me through the first hurdle of connecting to the shell, however I'm now having troubles connecting to the database, a similar problem to this thread -> http://www.yiiframew...php?topic=407.0

unfortunately, the solutions presented there don't work for me. if that helps running SHOW COLUMNS FROM User displays the following:

Quote

mysql> show columns from User

    -> ;

+------------+-----------------------+------+-----+---------+----------------+

| Field      | Type                  | Null | Key | Default | Extra          |

+------------+-----------------------+------+-----+---------+----------------+

| id        | int(11)              | NO  | PRI | NULL    | auto_increment |

| first_name | varchar(255)          | NO  |    | NULL    |                |

| last_name  | varchar(255)          | NO  |    | NULL    |                |

| username  | varchar(255)          | NO  |    | NULL    |                |

| password  | varchar(255)          | NO  |    | NULL    |                |

| type      | enum('Admin','Agent') | NO  |    | NULL    |                |

| last_login | date                  | NO  |    | NULL    |                |

| email      | varchar(255)          | NO  |    | NULL    |                |

+------------+-----------------------+------+-----+---------+----------------+

8 rows in set (0.00 sec)


Does the shell have issues with datatypes other than VARCHAR and INT by any chance?

Edit: Nevermind, I had to exit the shell and restart it and it now works... *sigh*
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users