Yii Framework Forum: failed to open PDO.php when running yiic - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

failed to open PDO.php when running yiic Rate Topic: -----

#1 User is offline   bruno_ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 02-July 09

Posted 21 July 2009 - 05:31 AM

Hi,

I've two web applications. The first is an intial web application just created by the webapp command. the second is a copy of the blog demo. I'm trying to add a categories management to this project. So I've created a table category and now want to create the model by command line. Unfortunately, it doesn't work.

I have this error message when trying to run yiic. Then message appears as an html document in the command prompt:

Quote

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

It happens here : J:\Developpement\serveur\yii\framework\YiiBase.php(316)
00307:     public static function autoload($className)
00308:     {
00309:         // use include so that the error PHP file may appear
00310:         if(isset(self::$_coreClasses[$className]))
00311:             include(YII_PATH.self::$_coreClasses[$className]);
00312:         else if(isset(self::$_classes[$className]))
00313:             include(self::$_classes[$className]);
00314:         else
00315:         {
00316: include($className.'.php');
00317:             return class_exists($className,false) || interface_exists($className,false);
00318:         }
00319:         return true;
00320:     }


Curiously, in the initial project, I can run yiic but not the model User command. I get pretty much the same error message, but as a prompt message
J:\Developpement\serveur\web>yiic shell test\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:\Developpement\serveur\yii\framework\YiiBase.php on line 316

Warning: include(): Failed opening 'PDO.php' for inclusion (include_path='.;C:\php5\pear;J:\Developpement\serveur\web\test\protected\models;
J:\Developpement\serveur\web\test\protected\components') in J:\Developpement\serveur\yii\framework\YiiBase.php on line 316

Fatal error: Class 'PDO' not found in J:\Developpement\serveur\yii\framework\db\CDbConnection.php on line 282

J:\Developpement\serveur\web>


Search I've done returned nothing. Does anybody could help me?

Kind regards,

Bruno.
0

#2 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 21 July 2009 - 06:18 AM

Accidentally aren't you using Yii 1.1 unstable version with unit testing enabled? I ran a quick search for PDO.php and only found it in PHPUnit.

If not, could you please submit call stack trace, so we can find out where the whole thing went wrong?
0

#3 User is offline   bruno_ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 02-July 09

Posted 21 July 2009 - 06:31 AM

I didn't either find the file! Apparently, I use yii 1.0.7 as the prompt show it. I've tested the requirements as well, and it shows me 1.0.7.

This is the html document generated. You'll find all informations about the error in it :
<!DOCTYPE html PUBLIC
        "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>
PHP Error</title>

<style type="text/css">
/*<![CDATA[*/
body {font-family:"Verdana";font-weight:normal;color:black;background-color:whit
e;}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-size:9pt;}
pre {font-family:"Lucida Console";font-size:10pt;}
.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
.message {color: maroon;}
.source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffe
e;}
.error {background-color: #ffeeee;}
/*]]>*/
</style>
</head>

<body>
<h1>PHP Error</h1>

<h3>Description</h3>
<p class="message">
include(PDO.php): failed to open stream: No such file or directory</p>

<h3>Source File</h3>
<p>
J:\Developpement\serveur\yii\framework\YiiBase.php(316)</p>

<div class="source">
<pre>
00304:      * @param string class name
00305:      * @return boolean whether the class has been loaded successfully
00306:      */
00307:     public static function autoload($className)
00308:     {
00309:         // use include so that the error PHP file may appear
00310:         if(isset(self::$_coreClasses[$className]))
00311:             include(YII_PATH.self::$_coreClasses[$className]);
00312:         else if(isset(self::$_classes[$className]))
00313:             include(self::$_classes[$className]);
00314:         else
00315:         {
<div class="error">00316:             include($className.'.php');
</div>00317:             return class_exists($className,false) || interface_exis
ts($className,false);
00318:         }
00319:         return true;
00320:     }
00321:
00322:     /**
00323:      * Writes a trace message.
00324:      * This method will only log a message when the application is in deb
ug mode.
00325:      * @param string message to be logged
00326:      * @param string category of the message
00327:      * @see log
00328:      */
</pre>
</div><!-- end of source -->

<h3>Stack Trace</h3>
<div class="callstack">
<pre>
#0 J:\Developpement\serveur\yii\framework\YiiBase.php(316): autoload()
#1 unknown(0): autoload()
#2 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(282): spl_autoloa
d_call()
#3 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(242): CDbConnecti
on-&gt;createPdoInstance()
#4 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(223): CDbConnecti
on-&gt;open()
#5 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(202): CDbConnecti
on-&gt;setActive()
#6 J:\Developpement\serveur\yii\framework\base\CModule.php(353): CDbConnection-&
gt;init()
#7 J:\Developpement\serveur\yii\framework\base\CApplication.php(338): CWebApplic
ation-&gt;getComponent()
#8 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(839): CWebAppl
ication-&gt;getDb()
#9 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(2153): Post-&g
t;getDbConnection()
#10 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(635): CActive
RecordMetaData-&gt;__construct()
#11 J:\Developpement\serveur\web\blogyii\protected\models\Post.php(15): model()
#12 J:\Developpement\serveur\web\blogyii\protected\controllers\PostController.ph
p(157): model()
#13 J:\Developpement\serveur\yii\framework\web\actions\CInlineAction.php(32): Po
stController-&gt;actionList()
#14 J:\Developpement\serveur\yii\framework\web\CController.php(300): CInlineActi
on-&gt;run()
#15 J:\Developpement\serveur\yii\framework\web\filters\CFilterChain.php(129): Po
stController-&gt;runAction()
#16 J:\Developpement\serveur\yii\framework\web\filters\CFilter.php(41): CFilterC
hain-&gt;run()
#17 J:\Developpement\serveur\yii\framework\web\CController.php(952): CAccessCont
rolFilter-&gt;filter()
#18 J:\Developpement\serveur\yii\framework\web\filters\CInlineFilter.php(59): Po
stController-&gt;filterAccessControl()
#19 J:\Developpement\serveur\yii\framework\web\filters\CFilterChain.php(126): CI
nlineFilter-&gt;filter()
#20 J:\Developpement\serveur\yii\framework\web\CController.php(283): CFilterChai
n-&gt;run()
#21 J:\Developpement\serveur\yii\framework\web\CController.php(257): PostControl
ler-&gt;runActionWithFilters()
#22 J:\Developpement\serveur\yii\framework\web\CWebApplication.php(332): PostCon
troller-&gt;run()
#23 J:\Developpement\serveur\yii\framework\web\CWebApplication.php(120): CWebApp
lication-&gt;runController()
#24 J:\Developpement\serveur\yii\framework\base\CApplication.php(133): CWebAppli
cation-&gt;processRequest()
#25 J:\Developpement\serveur\web\blogyii\index.php(11): CWebApplication-&gt;run(
)
#26 J:\Developpement\serveur\yii\framework\cli\commands\ShellCommand.php(78): re
quire()
#27 J:\Developpement\serveur\yii\framework\console\CConsoleCommandRunner.php(62)
: ShellCommand-&gt;run()
#28 J:\Developpement\serveur\yii\framework\console\CConsoleApplication.php(88):
CConsoleCommandRunner-&gt;run()
#29 J:\Developpement\serveur\yii\framework\base\CApplication.php(133): CConsoleA
pplication-&gt;processRequest()
#30 J:\Developpement\serveur\yii\framework\yiic.php(31): CConsoleApplication-&gt
;run()
#31 J:\Developpement\serveur\yii\framework\yiic(15): require_once()
</pre>
</div><!-- end of callstack -->

<div class="version">
2009-07-21 12:13:16 <a href="http://www.yiiframework.com/">Yii Framework</a>/1.0
.7</div>
</body>
</html>


Thanks for your help.
0

#4 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 21 July 2009 - 06:38 AM

Having a look at CDbConnection::createPdoInstance() gave me the feeling that you have misconfigured your db access details.

Make sure your database connection string in config.php contains ':'. If not, rewrite it while keeping conventions in front of your eyes:

Quote

SQLite: sqlite:/path/to/dbfile
MySQL: mysql:host=localhost;dbname=testdb
PostgreSQL: pgsql:host=localhost;port=5432;dbname=testdb
SQL Server: mssql:host=localhost;dbname=testdb
Oracle: oci:dbname=//localhost:1521/testdb

0

#5 User is offline   bruno_ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 02-July 09

Posted 21 July 2009 - 07:40 AM

I've checked and it's correct.
'connectionString'=>'mysql:host=localhost;dbname=blogyii',

I can access to the blog and create posts.
0

#6 User is offline   qiang 

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

Posted 21 July 2009 - 08:38 AM

The error means that you CLI php does not have PDO enabled. Check to make sure you CLI php is using the expected php.ini.
0

#7 User is offline   bruno_ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 02-July 09

Posted 21 July 2009 - 09:04 AM

Thanks a lot to both of you. It was it... Again! I forgot EasyPHP uses a php.ini file placed in the apache folder. Sorry for this "double" thread.

edit : we can't edit the title, it's too bad. It's useful for marking a thread as "solved".
0

#8 User is offline   kareem zok 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 18-January 10
  • Location:lebanon

Posted 18 January 2010 - 07:00 AM

View Postbruno_, on 21 July 2009 - 09:04 AM, said:

Thanks a lot to both of you. It was it... Again! I forgot EasyPHP uses a php.ini file placed in the apache folder. Sorry for this "double" thread.

edit : we can't edit the title, it's too bad. It's useful for marking a thread as "solved".


i m using wamp server nd i got same problem any solution coz i didnt get it nd i m still new in yiiframeworks ,
PS: what is CLI ?
Kareem zock
Software engineer

T: +(961) 03 497265
E: kareemzok@gmail.com
Skype: kareem_zok

Posted Image Linkedin

Posted Image Facebook

Posted Image Twitter

About me.com
0

#9 User is offline   WTF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 18-April 10
  • Location:Riga, Latvia

Posted 18 April 2010 - 05:10 AM

View Postkareem, on 18 January 2010 - 07:00 AM, said:

i m using wamp server nd i got same problem any solution coz i didnt get it nd i m still new in yiiframeworks ,
PS: what is CLI ?


I had the same problem on my server. Recompile php with pdo support resolve the problem.

Regards,
Andrejs.
0

#10 User is offline   Chris Backhouse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 04-August 11
  • Location:France

Posted 29 November 2011 - 02:32 AM

I've just spent hours trying to resolve this problem.

My development machine is a WAMP server, live server is nix based with PDO support enabled. I already run other Yii based sites so was particularly perplexed by this.

I had recently upgraded to Yii 1.1.8 and thought perhaps this was the problem...

No, as someone mentioned above, in the end it was down to a rogue php.ini file which I needed on the WAMP machine to increase the max execution time.

Phew !!!!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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