Fatal error: Class 'CException' not found in ... YiiBase.php


I’ve written a few pages which show a CGridView, allow some filters etc., and have an export button which uses EExcelView (www.yiiframework.com/extension/eexcelview) to output the grid as a file. It works fine on my development machine, but when I put it on the server (in debug mode, just the same as my machine), clicking export gives the following error ‘Fatal error: Class ‘CException’ not found in /var/www/yii/framework/YiiBase.php on line 321’.

Other exceptions get displayed just as normal, and indeed the rest of the site is absolutely fine, so I don’t think there can be anything wrong Yii’s code. So it must be something in my code or in EExcelView, but they work fine on my computer, and I can’t imagine what kind of error could prevent Yii from being able to load CException.

Yii version is 1.1.8 on both machines. PHP is 5.3.2 on my machine, but 5.1.6 on the server. The server is running CentOS and my machine is running Ubuntu.

Any help would be much appreciated.

This has been solved now.

The actual problem was that the permissions on phpexcel (which EExcelView imports) were set so that Yii couldn’t access them. The confusion happened because EExcelView disabled the yii autoloading function while it imported phpexcel (I think to hide an error that comes up when loading phpexcel otherwise). So when the error came up that yii couldn’t access phpexcel it couldn’t autoload CException so gave that fatal error.

I have the same problem, but I don’t know how to fix it. What was the right fix for you?


i ran into the same error, here is how i fix it

in file EExcelView.php

public function init()


	$this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();


	//Autoload fix


	Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);

	$this->objPHPExcel = new PHPExcel();


error happens in

Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);

due to this line, Yii could not find Class ‘CException’ which comes with autoload


so now, comment out this line first, Yii will throw user-friendly error message, fix the error (in my case, wrong import path for PHPExcel) and come back to remove the comment, voila!


Thank you very much. I will give it a try.


I had the same problem and I changed this path:

public static $phpExcelPathAlias = ‘ext.phpexcel.Classes.PHPExcel’;

to this:

public static $phpExcelPathAlias = ‘ext.PHPExcel.Classes.PHPExcel’;