failed to open PDO.php when running yiic


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 [font=“Courier New”]category[/font] and now want to create the model by command line. Unfortunately, it doesn’t work.

I have this error message when trying to run [font="Courier New"]yiic[/font]. Then message appears as an html document in the command prompt:

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 [font="Courier New"]yiic[/font] but not the [font="Courier New"]model User[/font] 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


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

Kind regards,


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?

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 :


        "-//W3C//DTD XHTML 1.0 Transitional//EN"


<html xmlns="" xml:lang="en" lang="en">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>


PHP Error</title>

<style type="text/css">


body {font-family:"Verdana";font-weight:normal;color:black;background-color:whit


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


.error {background-color: #ffeeee;}





<h1>PHP Error</h1>


<p class="message">

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

<h3>Source File</h3>



<div class="source">


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


00318:         }

00319:         return true;

00320:     }


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:      */


</div><!-- end of source -->

<h3>Stack Trace</h3>

<div class="callstack">


#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


#3 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(242): CDbConnecti


#4 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(223): CDbConnecti


#5 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(202): CDbConnecti


#6 J:\Developpement\serveur\yii\framework\base\CModule.php(353): CDbConnection-&


#7 J:\Developpement\serveur\yii\framework\base\CApplication.php(338): CWebApplic


#8 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(839): CWebAppl


#9 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(2153): Post-&g


#10 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(635): CActive


#11 J:\Developpement\serveur\web\blogyii\protected\models\Post.php(15): model()

#12 J:\Developpement\serveur\web\blogyii\protected\controllers\

p(157): model()

#13 J:\Developpement\serveur\yii\framework\web\actions\CInlineAction.php(32): Po


#14 J:\Developpement\serveur\yii\framework\web\CController.php(300): CInlineActi


#15 J:\Developpement\serveur\yii\framework\web\filters\CFilterChain.php(129): Po


#16 J:\Developpement\serveur\yii\framework\web\filters\CFilter.php(41): CFilterC


#17 J:\Developpement\serveur\yii\framework\web\CController.php(952): CAccessCont


#18 J:\Developpement\serveur\yii\framework\web\filters\CInlineFilter.php(59): Po


#19 J:\Developpement\serveur\yii\framework\web\filters\CFilterChain.php(126): CI


#20 J:\Developpement\serveur\yii\framework\web\CController.php(283): CFilterChai


#21 J:\Developpement\serveur\yii\framework\web\CController.php(257): PostControl


#22 J:\Developpement\serveur\yii\framework\web\CWebApplication.php(332): PostCon


#23 J:\Developpement\serveur\yii\framework\web\CWebApplication.php(120): CWebApp


#24 J:\Developpement\serveur\yii\framework\base\CApplication.php(133): CWebAppli


#25 J:\Developpement\serveur\web\blogyii\index.php(11): CWebApplication-&gt;run(


#26 J:\Developpement\serveur\yii\framework\cli\commands\ShellCommand.php(78): re


#27 J:\Developpement\serveur\yii\framework\console\CConsoleCommandRunner.php(62)

: ShellCommand-&gt;run()

#28 J:\Developpement\serveur\yii\framework\console\CConsoleApplication.php(88):


#29 J:\Developpement\serveur\yii\framework\base\CApplication.php(133): CConsoleA


#30 J:\Developpement\serveur\yii\framework\yiic.php(31): CConsoleApplication-&gt


#31 J:\Developpement\serveur\yii\framework\yiic(15): require_once()


</div><!-- end of callstack -->

<div class="version">

2009-07-21 12:13:16 <a href="">Yii Framework</a>/1.0




Thanks for your help.

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:

I’ve checked and it’s correct.


I can access to the blog and create posts.

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.

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 ?

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



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 !!!!